Say could not read when the trust file is not an object whose projects maps paths to objects #66

Merged
lilleman merged 4 commits from trust-file-shape into main 2026-09-26 15:17:49 +02:00
Showing only changes of commit df2b010fee - Show all commits
+6
View File
@@ -223,6 +223,12 @@ class Trust(unittest.TestCase):
with contextlib.redirect_stderr(io.StringIO()) as err:
loop.trust(["/a"])
self.assertIn(f"could not read {config}: ", err.getvalue())
for shape in ([], {"projects": []}, {"projects": {"/a": 1}}):
config.write_text(json.dumps(shape))
with contextlib.redirect_stderr(io.StringIO()) as err:
loop.trust(["/a"])
self.assertEqual(err.getvalue(), f"could not read {config}: not an object whose projects maps paths to objects\n")
self.assertEqual(json.loads(config.read_text()), shape)
data = {"other": 1, "projects": {"/a": {"hasTrustDialogAccepted": True, "kept": 2}}}
config.write_text(json.dumps(data))
with contextlib.redirect_stderr(io.StringIO()) as err: