Re-read already-uploaded tracks once so their profiles get power and temperature
This commit is contained in:
1 parent
ebd4852e98
commit
3e487539bc
4 files changed
+66
-1
No files matched your search
@@ -177,6 +177,23 @@ class LibraryTest < Minitest::Test
|
||||
assert_raises(Maptool::Library::NotFound) { library.export_gpx("nope") }
|
||||
end
|
||||
|
||||
def test_reparse_rereads_old_profiles_once_and_keeps_the_name
|
||||
library = open_library
|
||||
key = library.import(folder: "", filename: "ride.gpx", io: File.open(fixture_path("sample.gpx"))).find { |k| k.start_with?("item:") }
|
||||
id = key.delete_prefix("item:")
|
||||
# As if imported by an older parser: no profile yet, renamed since.
|
||||
db = SQLite3::Database.new(File.join(@dir, "library.sqlite"))
|
||||
props = JSON.parse(db.get_first_value("SELECT properties FROM items WHERE id = ?", [id]))
|
||||
db.execute("UPDATE items SET properties = ?, name = 'Mine' WHERE id = ?", [JSON.generate(props.except("profile").merge("color" => "#ff0000")), id])
|
||||
db.execute("UPDATE meta SET parser = 0")
|
||||
|
||||
assert_equal 1, library.reparse
|
||||
props = JSON.parse(db.get_first_value("SELECT properties FROM items WHERE id = ?", [id]))
|
||||
assert props["profile"].any?
|
||||
assert_equal "#ff0000", props["color"]
|
||||
assert_equal 0, library.reparse # done once
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def write_tmp(content)
|
||||
|
||||
Reference in new issue
Block a user