diff --git a/bin/record_store/test_stores.py b/bin/record_store/test_stores.py index da387637..1dc0df43 100644 --- a/bin/record_store/test_stores.py +++ b/bin/record_store/test_stores.py @@ -53,6 +53,18 @@ class FileStore(unittest.TestCase): self.assertIsInstance(written, Failure) self.assertIn(f"cannot write {path}: ", written.reason) + def test_a_write_makes_each_folder_the_file_lacks(self): + path = self.folder / "records" / "acme" / "decisions.md" + self.assertIsNone(stores.FileStore(path, None).write("text\n")) + self.assertEqual(path.read_text(), "text\n") + + def test_a_write_onto_a_folder_is_a_failure_naming_it(self): + path = self.folder / "decisions.md" + path.mkdir() + written = stores.FileStore(path, None).write("text\n") + self.assertIsInstance(written, Failure) + self.assertIn(f"cannot write {path}: ", written.reason) + def test_a_write_keeps_the_text_as_given_not_the_platforms_line_ends(self): path = self.folder / "decisions.md" stores.FileStore(path, None).write("one\r\ntwo\n") @@ -134,8 +146,9 @@ class Store(unittest.TestCase): self.assertEqual((store.label, store.tracked), ("/home/me/.claude-projects/acme/CHANGELOG.md", None)) def test_the_plan_is_not_a_record(self): - with self.assertRaises(ValueError): + with self.assertRaises(ValueError) as refused: stores.store(self.config(pathlib.Path("/code/acme"), pathlib.Path("/home/me/.claude-projects/acme")), "plan") + self.assertEqual(str(refused.exception), "plan is not a record; the records are decisions, score-anchors, comprehension-history, reading-cost, changelog") class OneWayIn(unittest.TestCase):