Test that a file store makes missing folders, fails on a folder and names the records it knows
This commit is contained in:
@@ -53,6 +53,18 @@ class FileStore(unittest.TestCase):
|
|||||||
self.assertIsInstance(written, Failure)
|
self.assertIsInstance(written, Failure)
|
||||||
self.assertIn(f"cannot write {path}: ", written.reason)
|
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):
|
def test_a_write_keeps_the_text_as_given_not_the_platforms_line_ends(self):
|
||||||
path = self.folder / "decisions.md"
|
path = self.folder / "decisions.md"
|
||||||
stores.FileStore(path, None).write("one\r\ntwo\n")
|
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))
|
self.assertEqual((store.label, store.tracked), ("/home/me/.claude-projects/acme/CHANGELOG.md", None))
|
||||||
|
|
||||||
def test_the_plan_is_not_a_record(self):
|
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")
|
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):
|
class OneWayIn(unittest.TestCase):
|
||||||
|
|||||||
Reference in New Issue
Block a user