Test that a trust file of the wrong shape is reported as unreadable
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user