Test the plan store's refusals and failed reads and writes, and print a row's R as the plan holds it
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import dataclasses
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -92,6 +93,30 @@ class FilePlan(FilePlanContract):
|
||||
self.new_store().add(FIRST | {"Score": "9"}, "")
|
||||
|
||||
|
||||
def test_refuses_a_tagline_with_a_line_break_and_a_detail_with_a_heading(self):
|
||||
store = self.new_store()
|
||||
id_ = self.filed(store, FIRST)
|
||||
before = (self.folder / "todo.md").read_text()
|
||||
broken, split = "the tagline holds a line break; keep it on one line", "the detail holds a ## or ### heading, which would split ## Details; use #### or drop the #s"
|
||||
self.assertEqual(store.add(FIRST | {stores.TAGLINE: "Count\nthe runs."}, ""), Failure(broken))
|
||||
self.assertEqual(store.add(FIRST, "## Why\n"), Failure(split))
|
||||
self.assertEqual(store.edit(id_, {stores.TAGLINE: "Count\nthe runs."}, None), Failure(broken))
|
||||
self.assertEqual(store.edit(id_, {}, "### Why\n"), Failure(split))
|
||||
self.assertEqual((self.folder / "todo.md").read_text(), before)
|
||||
|
||||
def test_a_file_it_cannot_write_fails_naming_it(self):
|
||||
store = self.new_store()
|
||||
self.folder.chmod(0o555)
|
||||
self.addCleanup(self.folder.chmod, 0o755)
|
||||
written = store.add(FIRST, "")
|
||||
assert isinstance(written, Failure), written
|
||||
self.assertTrue(written.reason.startswith(f"{self.folder / 'todo.md'}: "), written.reason)
|
||||
|
||||
def test_a_history_it_cannot_read_fails_every_write(self):
|
||||
store = dataclasses.replace(self.new_store(), history=MemoryStore(fails="no history"))
|
||||
self.assertEqual(store.add(FIRST, ""), Failure("no history"))
|
||||
|
||||
|
||||
class HeldAt(unittest.TestCase):
|
||||
def test_reads_the_revisions_file_where_commits_hold_the_plan(self):
|
||||
shown = []
|
||||
@@ -118,3 +143,6 @@ class HeldAt(unittest.TestCase):
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
def test_fails_where_the_revision_cannot_be_read(self):
|
||||
self.assertEqual(stores.held_at("origin/main", MemoryPlan(tracked="todo.md"), "/checkout", lambda *args, cwd: Failure("no git")), Failure("no git"))
|
||||
|
||||
Reference in New Issue
Block a user