test/rpm: add schema validation test for boot_root
This commit is contained in:
parent
2e45963aed
commit
e93cd75e5b
1 changed files with 28 additions and 0 deletions
28
stages/test/test_rpm.py
Normal file
28
stages/test/test_rpm.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import pytest
|
||||
|
||||
from osbuild import testutil
|
||||
|
||||
STAGE_NAME = "org.osbuild.rpm"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_data,expected_err", [
|
||||
# bad
|
||||
({"kernel_install_env": {"boot_root": "../rel"}}, "'../rel' does not match "),
|
||||
# good
|
||||
({}, ""),
|
||||
({"kernel_install_env": {"boot_root": "/boot"}}, ""),
|
||||
])
|
||||
def test_schema_validation(stage_schema, test_data, expected_err):
|
||||
test_input = {
|
||||
"type": STAGE_NAME,
|
||||
"options": {
|
||||
}
|
||||
}
|
||||
test_input["options"].update(test_data)
|
||||
res = stage_schema.validate(test_input)
|
||||
|
||||
if expected_err == "":
|
||||
assert res.valid is True, f"err: {[e.as_dict() for e in res.errors]}"
|
||||
else:
|
||||
assert res.valid is False
|
||||
testutil.assert_jsonschema_error_contains(res, expected_err, expected_num_errs=1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue