|
| 1 | +"""Which full scans ask the API to become their branch's head scan.""" |
| 2 | + |
| 3 | +from tests.core.test_strict_blocking_no_manifest_change import cli_runtime # noqa: F401 |
| 4 | + |
| 5 | + |
| 6 | +def _scan_params(runtime): |
| 7 | + runtime.full_scan.assert_called_once() |
| 8 | + return runtime.full_scan.call_args.args[1] |
| 9 | + |
| 10 | + |
| 11 | +def test_branch_scan_asks_to_be_the_branch_head(cli_runtime): # noqa: F811 |
| 12 | + # The API honors this only for tracked branches, so the CLI no longer decides. |
| 13 | + assert cli_runtime.run() == 0 |
| 14 | + |
| 15 | + params = _scan_params(cli_runtime) |
| 16 | + assert params.branch == "feature" |
| 17 | + assert params.set_as_pending_head is True |
| 18 | + assert params.make_default_branch is False |
| 19 | + |
| 20 | + |
| 21 | +def test_default_branch_scan_is_the_head_and_the_default_branch(cli_runtime): # noqa: F811 |
| 22 | + cli_runtime.git_repo.is_default_branch = True |
| 23 | + |
| 24 | + assert cli_runtime.run() == 0 |
| 25 | + |
| 26 | + params = _scan_params(cli_runtime) |
| 27 | + assert params.set_as_pending_head is True |
| 28 | + assert params.make_default_branch is True |
| 29 | + |
| 30 | + |
| 31 | +def test_pull_request_scan_is_never_a_head(cli_runtime): # noqa: F811 |
| 32 | + assert cli_runtime.run(["--pr-number", "42"]) == 0 |
| 33 | + |
| 34 | + params = _scan_params(cli_runtime) |
| 35 | + assert params.set_as_pending_head is False |
| 36 | + assert params.make_default_branch is False |
| 37 | + |
| 38 | + |
| 39 | +def test_no_default_branch_scan_is_never_a_head(cli_runtime): # noqa: F811 |
| 40 | + # --no-default-branch promises the scan won't become the default branch or a head. |
| 41 | + cli_runtime.git_repo.is_default_branch = True |
| 42 | + |
| 43 | + assert cli_runtime.run(["--no-default-branch"]) == 0 |
| 44 | + |
| 45 | + params = _scan_params(cli_runtime) |
| 46 | + assert params.set_as_pending_head is False |
| 47 | + assert params.make_default_branch is False |
0 commit comments