Test that the last-successful branch script updates successfully
(tmpdir_factory, statuses, expected_rc, expected_output)
| 481 | ), |
| 482 | ) |
| 483 | def test_update_branch(tmpdir_factory, statuses, expected_rc, expected_output): |
| 484 | """ |
| 485 | Test that the last-successful branch script updates successfully |
| 486 | """ |
| 487 | update_script = GITHUB_SCRIPT_ROOT / "update_branch.py" |
| 488 | |
| 489 | git = TempGit(tmpdir_factory.mktemp("tmp_git_dir")) |
| 490 | commit = { |
| 491 | "statusCheckRollup": {"contexts": {"nodes": statuses}}, |
| 492 | "oid": "123", |
| 493 | "messageHeadline": "hello", |
| 494 | } |
| 495 | data = { |
| 496 | "data": { |
| 497 | "repository": { |
| 498 | "defaultBranchRef": {"target": {"history": {"edges": [], "nodes": [commit]}}} |
| 499 | } |
| 500 | } |
| 501 | } |
| 502 | proc = run_script( |
| 503 | [update_script, "--dry-run", "--testonly-json", json.dumps(data)], |
| 504 | cwd=git.cwd, |
| 505 | check=False, |
| 506 | ) |
| 507 | |
| 508 | if proc.returncode != expected_rc: |
| 509 | raise RuntimeError(f"Wrong return code:\nstdout:\n{proc.stdout}\n\nstderr:\n{proc.stderr}") |
| 510 | |
| 511 | if expected_output not in proc.stdout: |
| 512 | raise RuntimeError( |
| 513 | f"Missing {expected_output}:\nstdout:\n{proc.stdout}\n\nstderr:\n{proc.stderr}" |
| 514 | ) |
| 515 | |
| 516 | |
| 517 | # pylint: disable=line-too-long |
nothing calls this directly
no test coverage detected
searching dependent graphs…