Created
October 23, 2025 17:37
-
-
Save dustymabe/20f86dc4b7a1447078940685b3336013 to your computer and use it in GitHub Desktop.
test/mod/test_util_containers.py
This file contains hidden or 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
| # cat test/mod/test_util_containers.py | |
| # | |
| # Test for util/containers.py | |
| # | |
| import textwrap | |
| import pytest | |
| import osbuild.testutil | |
| from osbuild.util import containers | |
| def test_container_mount_error(): | |
| fake_podman = textwrap.dedent("""\ | |
| #!/bin/sh | |
| echo "some msg on stdout" | |
| echo "other error on stderr" >&2 | |
| exit 1 | |
| """) | |
| input_image = { | |
| "filepath": "path", | |
| "manifest-list": "manifest-list-path", | |
| "data": {'name': 'foo', 'format': 'containers-storage'}, | |
| "checksum": "sha256:abcdabcd" | |
| } | |
| with tempfile.TemporaryDirectory(prefix='test-util-containers') as tmpd: | |
| with osbuild.testutil.make_container(tmpd, { | |
| "file1": "file1 content", | |
| }) as base_tag: | |
| image_id = subprocess.check_output(["podman", "inspect", "-f", "{{ .Id }}", base_tag], | |
| universal_newlines=True).strip() | |
| input_image['checksum'] = f"sha256:{image_id}" | |
| with osbuild.testutil.mock_command("podman", fake_podman): | |
| with pytest.raises(RuntimeError) as exp: | |
| with containers.container_mount(input_image): | |
| pass | |
| assert "some msg on stdout" not in str(exp.value) | |
| assert "other error on stderr" in str(exp.value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment