mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-23 18:21:42 +08:00
Add better assert, remove stdout/err redirect
This commit is contained in:
45
tests/integration/test_buildrequire_invalid_module.py
Normal file
45
tests/integration/test_buildrequire_invalid_module.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# SPDX-License-Identifier: MIT
|
||||
import pytest
|
||||
from sh import ErrorReturnCode
|
||||
|
||||
|
||||
# expected error message
|
||||
CANNOT_FIND_ANY_MODULE_BUILDS = "Cannot find any module builds" # ...
|
||||
|
||||
|
||||
def test_buildrequire_invalid_module(pkg_util, scenario, repo, koji):
|
||||
"""
|
||||
Run a build with with an invalid 'build_require' module.
|
||||
I.e.: required module is picked in such a way,
|
||||
that it is not tagged according to the the base module (platform) requirements,
|
||||
see platform's modulemd file and its 'koji_tag_with_modules' attribute
|
||||
(e.g.: platform: el-8.1.0 --> rhel-8.1.0-modules-build).
|
||||
|
||||
Koji resolver is expected to not be able to satisfy this build requirement
|
||||
and hence fail the build.
|
||||
|
||||
Assert that:
|
||||
* the module build hasn't been accepted by MBS:
|
||||
rhpkg utility returns something else than 0
|
||||
* "Cannot find any module build..." found on STDERR
|
||||
|
||||
If assert fails:
|
||||
* cancel all triggered module builds.
|
||||
|
||||
"""
|
||||
|
||||
repo.bump()
|
||||
|
||||
try:
|
||||
builds = pkg_util.run("--optional", "rebuild_strategy=all")
|
||||
|
||||
for build in builds:
|
||||
print("Canceling module-build {}...".format(build.id))
|
||||
pkg_util.cancel(build)
|
||||
|
||||
pytest.fail("Invalid 'build_require' was satisfied and module build was accepted by MBS!")
|
||||
|
||||
except ErrorReturnCode as e:
|
||||
# expected outcome: build submission fails
|
||||
assert CANNOT_FIND_ANY_MODULE_BUILDS in e.stderr.decode("utf-8")
|
||||
Reference in New Issue
Block a user