Add do-epic --dry-run, which prints the Jira writes planning would make and the chunks that would start, and makes none
CI / tests (pull_request) Failing after 2m36s

This commit is contained in:
Lilleman
2026-11-20 09:09:15 +01:00
parent e9e11f10a0
commit 1b022f4505
7 changed files with 271 additions and 19 deletions
+63
View File
@@ -968,6 +968,69 @@ class TheStatus(DoEpicTest):
self.assertIn("Jira answered 503\n", err)
class TheDryRun(DoEpicTest):
def setUp(self) -> None:
super().setUp()
for repo in ("api", "web"):
configured(self, self.home / "code" / repo, home=self.home)
(self.home / "code" / repo / "README.md").write_text("## Goals\nServe the API.\n\n## Audience\nIts callers.\n", encoding="utf-8")
self.stores: list[MemoryEpic] = []
made = self.backend
self.backend = lambda config, key: (self.stores.append(made(config, key)[0]) or self.stores[-1], EpicRecord(Description(self.description))) # type: ignore[method-assign,assignment]
def test_prints_each_write_and_each_chunk_it_would_start_and_makes_none_of_them(self) -> None:
self.issues = [issue("ABC-20"), issue("ABC-21", "do-epic-claude")]
parts = structured({"parts": [{"repo": "api", "change": "Add the endpoint."}, {"repo": "web", "change": "Call it."}], "comment": "Split by repo: api and web."})
fake = FakeEffects(on_terminal=True, claude=[parts])
code, out, err = self.run_main(["ABC-12", "--dry-run"], fake)
self.assertEqual((code, err), (0, ""))
shown = out.replace("<1790000000> ", "")
self.assertIn("planning would write to Jira:\n- file ABC-new1 under ABC-20: [api] Do ABC-20, labelled repo:api\n- file ABC-new2 under ABC-20: [web] Do ABC-20, labelled repo:web\n- comment on ABC-20: Split by repo: api and web.\n", shown)
self.assertIn("would start ABC-new1, ABC-new2\nABC-21 waits: the epic runs as many chunks as its `**Max parallel chunks:**` line allows: 2\n", shown)
self.assertEqual(self.stores[0].writes, [])
self.assertEqual([each.key for each in self.stores[0].issues], ["ABC-20", "ABC-21"])
changing = {"new-session", "new-window", "kill-window", "set-option", "rename-window"}
self.assertEqual([args for args in fake.tmux_calls if args[0] in changing], [])
def test_counts_the_chunks_it_would_start_against_the_epics_cap_and_a_repos_limit(self) -> None:
self.issues = [issue("ABC-21", "do-epic-claude"), issue("ABC-22", "do-epic-claude"), issue("ABC-23", "do-epic-claude")]
self.description = DESCRIPTION.replace("2", "1")
code, out, _ = self.run_main(["ABC-12", "--dry-run"], FakeEffects(on_terminal=True))
self.assertEqual(code, 0)
shown = out.replace("<1790000000> ", "")
self.assertIn("planning would write nothing to Jira\nwould start ABC-21\n", shown)
self.assertIn("ABC-22 waits: the epic runs as many chunks as its `**Max parallel chunks:**` line allows: 1\n", shown)
def test_prints_the_question_planning_would_ask_and_asks_none(self) -> None:
self.issues = [issue("ABC-20")]
unclear = structured({"pick": "unclear", "question": "Is the importer in api or in web?"})
fake = FakeEffects(on_terminal=True, claude=[structured({"parts": []}), unclear], inputs=["api"])
code, out, _ = self.run_main(["ABC-12", "--dry-run"], fake)
self.assertEqual(code, 0)
self.assertIn("ABC-20 waits for your answer: Is the importer in api or in web?", out)
self.assertEqual([seam for seam, _ in fake.calls if seam == "input"], [])
self.assertIn("planning would write nothing to Jira\n", out)
def test_works_without_tmux_and_a_chunk_in_a_missing_repo_waits(self) -> None:
self.issues = [issue("ABC-20", "repo:missing"), issue("ABC-21", "do-epic-claude")]
fake = FakeEffects(on_terminal=False, tmux_version="")
code, out, _ = self.run_main(["ABC-12", "--dry-run"], fake)
self.assertEqual(code, 0)
self.assertIn("would start ABC-21\n", out)
self.assertIn("ABC-20 waits:", out)
self.assertIn("ABC-20 waits: missing is missing", out)
self.assertEqual([what for seam, what in fake.calls if seam == "git" and "clone" in what], [])
def test_stops_where_the_epic_cannot_be_read(self) -> None:
store = MemoryEpic("ABC-12", [], fails="Jira answered 503")
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
code, _, err = self.run_main(["ABC-12", "--dry-run"], FakeEffects())
self.assertEqual((code, "Jira answered 503\n" in err), (1, True))
def test_is_in_the_help(self) -> None:
self.assertIn("--dry-run", main.HELP)
self.assertEqual(self.run_main(["ABC-12", "--dry-run", "--status"], FakeEffects())[0], 1)
if __name__ == "__main__":
unittest.main()