Skip to content

Commit

Permalink
test: small pytest related tweaks
Browse files Browse the repository at this point in the history
This commit tweaks the test setup slightly to use pytest.raises
for exception checking and also run test_mount_ostree_error()
only for the centos image (as the error checking/policies are
exactly the same for both images).
  • Loading branch information
mvo5 committed May 28, 2024
1 parent 017c424 commit 191a221
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,10 @@ def test_manifest_user_customizations_toml(tmp_path, build_container):
}


@pytest.mark.parametrize("image_type", gen_testcases("manifest"))
def test_mount_ostree_error(tmpdir_factory, build_container, image_type):
container_ref = image_type.split(",")[0]
def test_mount_ostree_error(tmpdir_factory, build_container):
# no need to parameterize this test, toml is the same for all containers
container_ref = "quay.io/centos-bootc/centos-bootc:stream9"

CFG = {
"blueprint": {
"customizations": {
Expand All @@ -245,7 +246,7 @@ def test_mount_ostree_error(tmpdir_factory, build_container, image_type):
{
"mountpoint": "/ostree",
"minsize": "10GiB"
}
},
]
},
},
Expand All @@ -256,16 +257,15 @@ def test_mount_ostree_error(tmpdir_factory, build_container, image_type):
config_json_path = output_path / "config.json"
config_json_path.write_text(json.dumps(CFG), encoding="utf-8")

try:
with pytest.raises(subprocess.CalledProcessError) as exc:
subprocess.check_output([
"podman", "run", "--rm",
"--privileged",
"-v", "/var/lib/containers/storage:/var/lib/containers/storage",
"--security-opt", "label=type:unconfined_t",
"-v", f"{output_path}:/output",
f'--entrypoint=["/usr/bin/bootc-image-builder", "manifest", "{container_ref}"]',
build_container,
"--config", "/output/config.json",
], stderr=subprocess.PIPE)
assert False, "Did not raise a CalledProcessError when mounting /ostree"
except subprocess.CalledProcessError as err:
assert 'The following custom mountpoints are not supported ["/ostree"]' in err.stderr.decode("utf-8")
], stderr=subprocess.PIPE, encoding="utf8")
assert 'The following custom mountpoints are not supported ["/ostree"]' in exc.value.stderr

0 comments on commit 191a221

Please sign in to comment.