Answer product-owner round 1: 0 🔴, 2 🟡 (0 misread); print the checks even where the epic stays, stop a do-epic that hangs, and state the sandbox's needs in the README

This commit is contained in:
2026-11-19 03:09:36 +01:00
parent 098bfddef9
commit b00470996b
6 changed files with 81 additions and 20 deletions
+51 -1
View File
@@ -2,11 +2,14 @@ import contextlib
import io
import pathlib
import sys
import typing
import tempfile
import unittest
from unittest import mock
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
from do_epic.e2e import main
from do_epic.e2e import main, sandbox, scenario
from do_epic.e2e.settings import ENV_FILE, JIRA_URL, PROJECT
@@ -30,3 +33,50 @@ class MainTest(unittest.TestCase):
code, out, err = self.run_main(["--status"])
self.assertEqual((code, out), (1, ""))
self.assertIn("usage: do-epic-e2e", err)
class ReportedTest(unittest.TestCase):
def setUp(self) -> None:
made = tempfile.TemporaryDirectory()
self.addCleanup(made.cleanup)
env_file = pathlib.Path(made.name) / "jira.env"
env_file.write_text("ATLASSIAN_EMAIL=a@example.com\nATLASSIAN_API_TOKEN=secret\n", encoding="utf-8")
env_file.chmod(0o600)
self.env = {JIRA_URL: "https://acme.atlassian.net", ENV_FILE: str(env_file), PROJECT: "SBX"}
def run_scenario(self, deleted: bool) -> tuple[int, str, str]:
@contextlib.contextmanager
def epic_made(*args: object) -> typing.Iterator[str]:
yield "SBX-1"
if not deleted:
raise sandbox.Leftover("SBX-1 is still there")
out, err = io.StringIO(), io.StringIO()
report = scenario.Report(["a check held"], ["a check broke"])
with mock.patch.object(sandbox, "epic_made", epic_made), mock.patch.object(scenario, "run", return_value=report):
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
code = main.main([], self.env, pathlib.Path("do-epic"))
return code, out.getvalue(), err.getvalue()
def test_prints_each_check_and_fails_where_one_broke(self) -> None:
code, out, err = self.run_scenario(True)
self.assertEqual((code, err), (1, ""))
self.assertIn("ok a check held\nFAIL a check broke\n1 held, 1 broke", out)
def test_prints_the_checks_and_names_the_epic_left_behind_when_it_cannot_be_deleted(self) -> None:
code, out, err = self.run_scenario(False)
self.assertEqual(code, 1)
self.assertIn("ok a check held", out)
self.assertIn("SBX-1 is still there", err)
class MachineTest(unittest.TestCase):
def test_stops_a_do_epic_that_runs_over_its_time_and_says_so(self) -> None:
with tempfile.TemporaryDirectory() as folder:
slow = pathlib.Path(folder) / "slow"
slow.write_text("#!/bin/sh\nsleep 30\n", encoding="utf-8")
slow.chmod(0o755)
with mock.patch.object(scenario, "TIMEOUT", 1):
done = scenario.Machine(pathlib.Path(folder), slow).do_epic("ABC-1")
self.assertEqual(done.returncode, 124)
self.assertIn("ran over 1 seconds", done.stderr)