Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and test the build/test targets in the CoprBuildHandler
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
- Loading branch information
1 parent
f37a635
commit c492d83
Showing
2 changed files
with
127 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import pytest | ||
from flexmock import flexmock | ||
from packit.config import PackageConfig, JobConfig, JobType, JobTriggerType | ||
|
||
from packit_service.worker.copr_build import CoprBuildHandler | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"jobs,build_targets,test_targets", | ||
[ | ||
pytest.param( | ||
[ | ||
JobConfig( | ||
job=JobType.copr_build, | ||
trigger=JobTriggerType.pull_request, | ||
metadata={"targets": ["fedora-29", "fedora-31"]}, | ||
) | ||
], | ||
{"fedora-29-x86_64", "fedora-31-x86_64"}, | ||
set(), | ||
id="build_with_targets", | ||
), | ||
pytest.param( | ||
[ | ||
JobConfig( | ||
job=JobType.copr_build, | ||
trigger=JobTriggerType.pull_request, | ||
metadata={}, | ||
) | ||
], | ||
{"fedora-30-x86_64", "fedora-31-x86_64"}, | ||
set(), | ||
id="build_without_targets", | ||
), | ||
pytest.param( | ||
[ | ||
JobConfig( | ||
job=JobType.tests, trigger=JobTriggerType.pull_request, metadata={}, | ||
) | ||
], | ||
{"fedora-30-x86_64", "fedora-31-x86_64"}, | ||
{"fedora-30-x86_64", "fedora-31-x86_64"}, | ||
id="test_without_targets", | ||
), | ||
pytest.param( | ||
[ | ||
JobConfig( | ||
job=JobType.tests, | ||
trigger=JobTriggerType.pull_request, | ||
metadata={"targets": ["fedora-29", "fedora-31"]}, | ||
) | ||
], | ||
{"fedora-29-x86_64", "fedora-31-x86_64"}, | ||
{"fedora-29-x86_64", "fedora-31-x86_64"}, | ||
id="test_with_targets", | ||
), | ||
pytest.param( | ||
[ | ||
JobConfig( | ||
job=JobType.copr_build, | ||
trigger=JobTriggerType.pull_request, | ||
metadata={}, | ||
), | ||
JobConfig( | ||
job=JobType.tests, trigger=JobTriggerType.pull_request, metadata={}, | ||
), | ||
], | ||
{"fedora-30-x86_64", "fedora-31-x86_64"}, | ||
{"fedora-30-x86_64", "fedora-31-x86_64"}, | ||
id="build_without_target&test_without_targets", | ||
), | ||
pytest.param( | ||
[ | ||
JobConfig( | ||
job=JobType.copr_build, | ||
trigger=JobTriggerType.pull_request, | ||
metadata={"targets": ["fedora-29", "fedora-31"]}, | ||
), | ||
JobConfig( | ||
job=JobType.tests, trigger=JobTriggerType.pull_request, metadata={}, | ||
), | ||
], | ||
{"fedora-29-x86_64", "fedora-31-x86_64"}, | ||
{"fedora-29-x86_64", "fedora-31-x86_64"}, | ||
id="build_with_target&test_without_targets", | ||
), | ||
pytest.param( | ||
[ | ||
JobConfig( | ||
job=JobType.copr_build, | ||
trigger=JobTriggerType.pull_request, | ||
metadata={}, | ||
), | ||
JobConfig( | ||
job=JobType.tests, | ||
trigger=JobTriggerType.pull_request, | ||
metadata={"targets": ["fedora-29", "fedora-31"]}, | ||
), | ||
], | ||
{"fedora-29-x86_64", "fedora-31-x86_64"}, | ||
{"fedora-29-x86_64", "fedora-31-x86_64"}, | ||
id="build_without_target&test_with_targets", | ||
), | ||
], | ||
) | ||
def test_targets(jobs, build_targets, test_targets): | ||
copr_build_handler = CoprBuildHandler( | ||
config=flexmock(), | ||
package_config=PackageConfig(jobs=jobs), | ||
project=flexmock(), | ||
event=flexmock(), | ||
) | ||
|
||
assert set(copr_build_handler.build_chroots) == build_targets | ||
assert set(copr_build_handler.tests_chroots) == test_targets |