feat: execute durable syncthing route setup
This commit is contained in:
@@ -51,6 +51,41 @@ class ClientStoreTests(unittest.TestCase):
|
||||
2, 3, False,
|
||||
)
|
||||
|
||||
def test_route_attempt_nonce_and_updates_survive_duplicate_commands(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
store = ClientStore(Path(directory) / "state.db")
|
||||
store.initialize()
|
||||
command_id = str(uuid4())
|
||||
store.accept_command(command_id, '{"route":"one"}', '{"ok":true}')
|
||||
first = store.begin_route_attempt(
|
||||
command_id, "route-1", '{"routeId":"route-1"}', "nonce-1"
|
||||
)
|
||||
duplicate = store.begin_route_attempt(
|
||||
command_id, "route-1", '{"routeId":"route-1"}', "new-nonce"
|
||||
)
|
||||
self.assertEqual(first["nonce"], "nonce-1")
|
||||
self.assertEqual(duplicate["nonce"], "nonce-1")
|
||||
store.record_route_update(
|
||||
command_id, 1, "provisioning", '{"sequence":1}'
|
||||
)
|
||||
store.record_route_ownership(command_id, True, True)
|
||||
store.record_route_update(
|
||||
command_id, 1, "provisioning", '{"sequence":1}'
|
||||
)
|
||||
store.record_route_update(
|
||||
command_id, 2, "ready", '{"sequence":2}'
|
||||
)
|
||||
self.assertEqual(store.get_route_attempt(command_id)["state"], "ready")
|
||||
self.assertEqual(store.get_route_attempt(command_id)["created_folder"], 1)
|
||||
self.assertEqual(
|
||||
[row["sequence"] for row in store.route_update_rows(command_id)],
|
||||
[1, 2],
|
||||
)
|
||||
with self.assertRaises(CommandConflict):
|
||||
store.record_route_update(
|
||||
command_id, 2, "ready", '{"sequence":2,"changed":true}'
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user