Answer stability round 1: 1 🔴, 5 🟡 (0 misread); hold a pull request's base on the forge to the recorded one, ask origin for the epic branch, and name where a chunk's work landed
CI / tests (pull_request) Successful in 3m46s
CI / tests (pull_request) Successful in 3m46s
This commit is contained in:
+29
-1
@@ -9,7 +9,7 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from forge.pulls import BEHIND, CheckFailed, checks_now, checks_passed, CONFLICTS, open_pull, Pending, POLL_SECONDS, ready_pulls, ReadyPull, required_checks, unmergeable, WAIT_SECONDS
|
||||
from forge.pulls import BEHIND, CheckFailed, checks_now, checks_passed, CONFLICTS, open_pull, other_base, Pending, POLL_SECONDS, ready_pulls, ReadyPull, required_checks, unmergeable, WAIT_SECONDS
|
||||
from failure import Failure
|
||||
from forge.commands import forge_of, gitea, runner, url_beside
|
||||
|
||||
@@ -86,6 +86,34 @@ class Unmergeable(unittest.TestCase):
|
||||
self.assertEqual(unmergeable("tea", "7", lambda command: '{"number": 7}').reason, "tea api answered pull request 7 in a shape that can't be read: {'number': 7}")
|
||||
|
||||
|
||||
class OtherBase(unittest.TestCase):
|
||||
ELSEWHERE = "pull request #7 merges into main on the forge, but this checkout takes ABC-12 as the base of its branch; a person settles which holds, and changes the pull request's base on the forge or the branch's `chunk-base` in git's config"
|
||||
|
||||
def test_a_github_pull_request_into_the_base_given_passes_and_one_into_another_fails_naming_both(self):
|
||||
commands: list[list[str]] = []
|
||||
self.assertIsNone(other_base("gh", "7", "main", lambda command: commands.append(command) or '{"baseRefName": "main"}'))
|
||||
self.assertEqual(commands, [["gh", "pr", "view", "7", "--json", "baseRefName"]])
|
||||
self.assertEqual(other_base("gh", "7", "ABC-12", lambda command: '{"baseRefName": "main"}'), Failure(self.ELSEWHERE))
|
||||
|
||||
def test_a_gitea_pull_request_into_the_base_given_passes_and_one_into_another_fails_naming_both(self):
|
||||
commands: list[list[str]] = []
|
||||
self.assertIsNone(other_base("tea", "7", "main", lambda command: commands.append(command) or '{"number": 7, "base": {"ref": "main"}}'))
|
||||
self.assertEqual(commands, [["tea", "api", "repos/{owner}/{repo}/pulls/7"]])
|
||||
self.assertEqual(other_base("tea", "7", "ABC-12", lambda command: '{"number": 7, "base": {"ref": "main"}}'), Failure(self.ELSEWHERE))
|
||||
|
||||
def test_fails_where_the_forge_cannot_be_read_or_names_no_base(self):
|
||||
unread = Failure("no network")
|
||||
for forge in ("gh", "tea"):
|
||||
with self.subTest(forge=forge):
|
||||
self.assertIs(other_base(forge, "7", "main", lambda command: unread), unread)
|
||||
self.assertEqual(other_base("gh", "7", "main", lambda command: LONG).reason, f"gh pr view printed no base branch: {LONG[:200]}")
|
||||
self.assertEqual(other_base("gh", "7", "main", lambda command: "not json").reason, "gh pr view printed no base branch: not json")
|
||||
self.assertEqual(other_base("gh", "7", "main", lambda command: '{"baseRefName": ""}').reason, 'gh pr view printed no base branch: {"baseRefName": ""}')
|
||||
self.assertEqual(other_base("tea", "7", "main", lambda command: LONG).reason, f"tea api answered pull request 7 in a shape that can't be read: {LONG[:200]}")
|
||||
self.assertEqual(other_base("tea", "7", "main", lambda command: '{"number": 7, "base": {}}').reason, "tea api answered pull request 7 in a shape that can't be read: {'number': 7, 'base': {}}")
|
||||
self.assertEqual(other_base("tea", "7", "main", lambda command: '{"number": 7, "base": {"ref": null}}').reason, "tea api answered pull request 7 in a shape that can't be read: {'number': 7, 'base': {'ref': None}}")
|
||||
|
||||
|
||||
def tea(statuses: typing.Iterable[str], branch: str = '{"name": "main"}') -> typing.Callable[[list[str]], str]:
|
||||
"""A tea answering each read of the head's status with the next of statuses, and of branch main with branch."""
|
||||
answers = iter(statuses)
|
||||
|
||||
Reference in New Issue
Block a user