Test that a trust file of the wrong shape is reported as unreadable

This commit is contained in:
2026-09-26 15:13:11 +02:00
parent 0ccbfa4a3b
commit df2b010fee
+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: