Kill the mutants that survived on the epic branch's changed lines
CI / tests (pull_request) Successful in 3m45s
CI / tests (pull_request) Successful in 3m45s
This commit is contained in:
@@ -88,7 +88,7 @@ class Checkout:
|
||||
|
||||
def __call__(self, command: list[str]) -> str | Failure:
|
||||
if command[:3] == ["git", "config", "--get"] and command[3].endswith(".chunk-base"):
|
||||
return self.chunk_base
|
||||
return self.chunk_base if command[3] == f"branch.{str(self.answers[('git', 'symbolic-ref', '--short', 'HEAD')]).strip()}.chunk-base" else ""
|
||||
self.ran.append(command)
|
||||
if command[0] == ("tea" if self.github else "gh"):
|
||||
return Failure(f"{command[0]} on the wrong forge")
|
||||
@@ -1087,6 +1087,42 @@ class EpicBranch(unittest.TestCase):
|
||||
checkout.answers[tuple(self.COMMENT_GH)] = Failure("gh pr comment: denied")
|
||||
self.assertEqual(step(["ready"], checkout, checkout.config), Failure("marked pull request #12 ready, but could not ask for a review: gh pr comment: denied"))
|
||||
|
||||
def test_a_pull_request_the_forge_does_not_mark_ready_gets_no_review_request(self):
|
||||
checkout = self.checkout()
|
||||
checkout.answers[("gh", "pr", "ready", "12")] = Failure("gh pr ready: denied")
|
||||
self.assertEqual(step(["ready"], checkout, checkout.config), Failure("gh pr ready: denied"))
|
||||
self.assertNotIn(self.COMMENT_GH, checkout.ran)
|
||||
|
||||
def test_a_push_whose_review_request_fails_says_the_branch_was_pushed_and_why_no_review_was_asked_for(self):
|
||||
refused = self.checkout()
|
||||
refused.answers[tuple(self.COMMENT_GH)] = Failure("gh pr comment: denied")
|
||||
unconfigured = self.checkout()
|
||||
unconfigured.answers[(PROJECT_CONFIG, "review-request-comment")] = Failure("no config names the checkout")
|
||||
for checkout, reason in ((refused, "gh pr comment: denied"), (unconfigured, "no config names the checkout")):
|
||||
with self.subTest(reason):
|
||||
self.assertEqual(step(["push"], checkout, checkout.config), Failure(f"pushed item-7, but could not ask for a review: {reason}"))
|
||||
self.assertIn(PUSH, checkout.ran)
|
||||
|
||||
def detached_on_second_read(self, checkout: Checkout) -> Run:
|
||||
"""checkout, whose HEAD reads as detached from the second time the branch checked out is read."""
|
||||
reads: list[list[str]] = []
|
||||
|
||||
def run(command: list[str]) -> str | Failure:
|
||||
if command == ["git", "symbolic-ref", "--short", "HEAD"]:
|
||||
reads.append(command)
|
||||
if len(reads) > 1:
|
||||
return Failure("git symbolic-ref: HEAD is detached")
|
||||
return checkout(command)
|
||||
return run
|
||||
|
||||
def test_a_branch_that_cannot_be_read_again_fails_the_push_review_request_and_the_merge(self):
|
||||
checkout = self.checkout()
|
||||
self.assertEqual(step(["push"], self.detached_on_second_read(checkout), checkout.config), Failure("pushed item-7, but could not ask for a review: git symbolic-ref: HEAD is detached"))
|
||||
self.assertNotIn(self.COMMENT_GH, checkout.ran)
|
||||
checkout = self.checkout()
|
||||
self.assertEqual(step(["merge"], self.detached_on_second_read(checkout), checkout.config), Failure("git symbolic-ref: HEAD is detached"))
|
||||
self.assertNotIn(["gh", "pr", "merge"], [command[:3] for command in checkout.ran])
|
||||
|
||||
def test_push_pushes_the_branch_and_asks_for_a_review_of_the_new_head(self):
|
||||
checkout = self.checkout()
|
||||
self.assertEqual(step(["push"], checkout, checkout.config), "Pushed item-7, and asked for a review of pull request #12 with “@reviewer review”.")
|
||||
@@ -1125,8 +1161,17 @@ class EpicBranch(unittest.TestCase):
|
||||
checkout.answers[("git", "rev-list", "--count", "origin/ABC-1..origin/main")] = "3\n"
|
||||
checkout.answers[("git", "merge-tree", "--write-tree", "origin/ABC-1", "origin/main")] = "7ree\n"
|
||||
checkout.answers[("git", "commit-tree", "7ree", "-p", "origin/ABC-1", "-p", "origin/main", "-m", "Merge remote-tracking branch 'origin/main' into ABC-1")] = "c0mm17\n"
|
||||
self.assertIn("Merged origin/main into origin/ABC-1. Opened", str(step(["open-epic", "ABC-1", "Ship the epic"], checkout, checkout.config)))
|
||||
self.assertEqual(step(["open-epic", "ABC-1", "Ship the epic"], checkout, checkout.config), "Merged origin/main into origin/ABC-1. Opened the pull request from ABC-1 into main, which a person merges.")
|
||||
self.assertIn(["git", "push", "--quiet", "origin", "c0mm17:refs/heads/ABC-1"], checkout.ran)
|
||||
self.assertEqual(checkout.acted()[-1], ["gh", "pr", "create", "--head", "ABC-1", "--base", "main", "--title", "Ship the epic", "--body", ""])
|
||||
|
||||
def test_open_epic_returns_a_failed_fetch_or_create(self):
|
||||
unfetched = self.epic()
|
||||
unfetched.answers[tuple(FETCH)] = Failure("git fetch: offline")
|
||||
self.assertEqual(step(["open-epic", "ABC-1", "Ship the epic"], unfetched, unfetched.config), Failure("git fetch: offline"))
|
||||
uncreated = self.epic()
|
||||
uncreated.answers[("gh", "pr", "create", "--head", "ABC-1", "--base", "main", "--title", "Ship the epic", "--body", "")] = Failure("gh pr create: denied")
|
||||
self.assertEqual(step(["open-epic", "ABC-1", "Ship the epic"], uncreated, uncreated.config), Failure("gh pr create: denied"))
|
||||
|
||||
def test_open_epic_leaves_a_conflict_with_the_default_branch_to_a_person_and_opens_nothing(self):
|
||||
checkout = self.epic()
|
||||
@@ -1155,10 +1200,11 @@ class EpicBranch(unittest.TestCase):
|
||||
self.assertEqual(unset.ran, [])
|
||||
checkout = self.epic()
|
||||
self.assertEqual(step(["open-epic", "ABC-1", "Ship\nit"], checkout, checkout.config), Failure("give a title of one line"))
|
||||
self.assertEqual(step(["open-epic", "ABC-1"], checkout, checkout.config), Failure(USAGE))
|
||||
for malformed in (["open-epic", "ABC-1"], ["open-epic", "ABC-1", "Ship it", "Body", "More"], ["open-epic", "--help", "Ship it"], ["open-epic", "ABC-1", "-Ship it"]):
|
||||
with self.subTest(malformed):
|
||||
self.assertEqual(step(malformed, checkout, checkout.config), Failure(USAGE))
|
||||
self.assertEqual(step(["open-epic", "abc/../1", "Ship it"], checkout, checkout.config), Failure("'abc/../1' is no epic's key, such as ABC-123"))
|
||||
self.assertEqual(checkout.ran, [])
|
||||
self.assertEqual(checkout.ran, [])
|
||||
|
||||
|
||||
class Launcher(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user