Skip to content

Commit

Permalink
Add a test for production_build deprecation
Browse files Browse the repository at this point in the history
Signed-off-by: Frantisek Lachman <[email protected]>
  • Loading branch information
lachmanfrantisek committed Oct 11, 2022
1 parent cfe8432 commit 5dfbef9
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions tests/integration/test_check_rerun.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,78 @@ def test_check_rerun_pr_koji_build_handler(
assert first_dict_value(results["job"])["success"]


@pytest.mark.parametrize(
"mock_pr_functionality",
(
[
[
{
"trigger": "pull_request",
"job": "production_build",
"metadata": {"targets": "fedora-all", "scratch": "true"},
}
]
]
),
indirect=True,
)
def test_check_rerun_pr_koji_build_handler_old_job_name(
mock_pr_functionality, check_rerun_event_koji_build
):
flexmock(KojiBuildJobHelper).should_receive("run_koji_build").and_return(
TaskResults(success=True, details={})
)
flexmock(GithubProject).should_receive("get_files").and_return(["foo.spec"])
flexmock(GithubProject).should_receive("get_web_url").and_return(
"https://github.com/the-namespace/the-repo"
)
flexmock(GithubProject).should_receive("is_private").and_return(False)
flexmock(koji_build).should_receive("get_koji_targets").and_return(
{"rawhide", "f34"}
)
flexmock(StatusReporterGithubChecks).should_receive("set_status").with_args(
state=BaseCommitStatus.neutral,
description="Job name `production_build` deprecated.",
check_name="config-deprecation-production_build",
url="https://packit.dev/docs/configuration/#supported-jobs",
links_to_external_services=None,
markdown_content="The `production_build` name for upstream Koji build is misleading "
"because it is not used to run production/non-scratch builds and "
"because it can be confused with "
"the `koji_build` job that is triggered for dist-git commits. "
"(The `koji_build` job can trigger both scratch and "
"non-scratch/production builds.) "
"To be explicit, use `upstream_koji_build` for builds triggered in upstream and "
"`koji_build` for builds triggered in downstream.\n\n"
"This status will be switched to a warning since November and "
"the support for the old name will be removed by the end of the year.",
).once()
flexmock(StatusReporterGithubChecks).should_receive("set_status").with_args(
state=BaseCommitStatus.pending,
description=TASK_ACCEPTED,
check_name="koji-build:f34",
url="",
links_to_external_services=None,
markdown_content=None,
).once()
flexmock(Signature).should_receive("apply_async").once()
flexmock(Pushgateway).should_receive("push").twice().and_return()

processing_results = SteveJobs().process_message(check_rerun_event_koji_build)
event_dict, job, job_config, package_config = get_parameters_from_results(
processing_results
)
assert json.dumps(event_dict)
assert event_dict["build_targets_override"] == ["f34"]

results = run_koji_build_handler(
package_config=package_config,
event=event_dict,
job_config=job_config,
)
assert first_dict_value(results["job"])["success"]


@pytest.mark.parametrize(
"mock_push_functionality",
(
Expand Down

0 comments on commit 5dfbef9

Please sign in to comment.