Shared trip: one itinerary per server (data/trip.json, GET/PUT /api/trip, routed server-side), the route panel edits it when logged in and polls other screens' changes in without moving the camera; the GNSS simulation skips trips under 1 km and starts elsewhere when it can't get on from a road island; the car's server updates itself from a topbar button (SELF_UPDATE=1: newer main with CI passed → bin/update-maptool.sh via maptool-update.path); Android Auto and the trip's next steps in TODO
This commit is contained in:
1 parent
5f4c7c6ee8
commit
17891c53b5
16 files changed
+513
-5
No files matched your search
@@ -0,0 +1,34 @@
|
||||
require_relative "test_helper"
|
||||
require "tmpdir"
|
||||
require_relative "../lib/maptool/updater"
|
||||
|
||||
class UpdaterTest < Minitest::Test
|
||||
def setup
|
||||
Maptool::Updater.reset!
|
||||
end
|
||||
|
||||
def test_latest_is_mains_commit_and_its_ci_state_cached_until_checked_again
|
||||
calls = []
|
||||
fetch = lambda do |url|
|
||||
calls << url
|
||||
url.end_with?("/branches/main") ? { "commit" => { "id" => "a" * 40 } } : { "state" => "success" }
|
||||
end
|
||||
assert_equal({ sha: "a" * 40, ci: "success" }, Maptool::Updater.latest("https://git", "r/m", fetch: fetch))
|
||||
assert_equal ["https://git/api/v1/repos/r/m/branches/main", "https://git/api/v1/repos/r/m/commits/#{'a' * 40}/status"], calls
|
||||
Maptool::Updater.latest("https://git", "r/m", fetch: fetch)
|
||||
assert_equal 2, calls.size # cached
|
||||
end
|
||||
|
||||
def test_gitea_out_of_reach_is_no_answer_not_an_error
|
||||
assert_nil Maptool::Updater.latest("https://git", "r/m", fetch: ->(_) { raise SocketError })
|
||||
end
|
||||
|
||||
def test_a_request_holds_a_full_commit_only
|
||||
Dir.mktmpdir do |dir|
|
||||
assert_raises(ArgumentError) { Maptool::Updater.request(dir, "abc; rm -rf /") }
|
||||
Maptool::Updater.request(dir, "b" * 40)
|
||||
assert_equal "b" * 40, JSON.parse(File.read(File.join(dir, "update", "request.json")))["sha"]
|
||||
assert_nil Maptool::Updater.status(dir)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user