testutil: make_container context manager
Make make_container a context manager so we can reliably clean up containers that were created in tests.
This commit is contained in:
parent
d6cd4b93ba
commit
591593ea00
3 changed files with 35 additions and 34 deletions
|
|
@ -17,12 +17,12 @@ SOURCES_NAME = "org.osbuild.containers-storage"
|
|||
@pytest.mark.skipif(os.getuid() != 0, reason="root only")
|
||||
def test_containers_storage_integration(tmp_path, sources_module):
|
||||
base_tag = "container-" + "".join(random.choices(string.digits, k=12))
|
||||
make_container(tmp_path, base_tag, {
|
||||
with make_container(tmp_path, base_tag, {
|
||||
"file1": "file1 content",
|
||||
})
|
||||
image_id = subprocess.check_output(["podman", "inspect", "-f", "{{ .Id }}", base_tag],
|
||||
universal_newlines=True).strip()
|
||||
checksum = f"sha256:{image_id}"
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
cnt_storage = sources_module.ContainersStorageSource.from_args(["--service-fd", str(sock.fileno())])
|
||||
assert cnt_storage.exists(checksum, None)
|
||||
}):
|
||||
image_id = subprocess.check_output(["podman", "inspect", "-f", "{{ .Id }}", base_tag],
|
||||
universal_newlines=True).strip()
|
||||
checksum = f"sha256:{image_id}"
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
cnt_storage = sources_module.ContainersStorageSource.from_args(["--service-fd", str(sock.fileno())])
|
||||
assert cnt_storage.exists(checksum, None)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue