test: return container_id in make_container

The current `make_container()` helper is a bit silly (which is
entirely my fault). It requires a container tag as input but all
tests end up creating a random number for this input. So instead
just remove the input and return the container_id from the podman
build in the contextmanager and use that.
This commit is contained in:
Michael Vogt 2024-03-11 19:16:30 +01:00 committed by Achilleas Koutsou
parent df224fb32b
commit fd0167f130
5 changed files with 49 additions and 24 deletions

View file

@ -1,9 +1,7 @@
#!/usr/bin/python3
import os
import random
import socket
import string
import subprocess
import pytest
@ -16,10 +14,9 @@ SOURCES_NAME = "org.osbuild.containers-storage"
@pytest.mark.skipif(not has_executable("podman"), reason="no podman executable")
@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))
with make_container(tmp_path, base_tag, {
with make_container(tmp_path, {
"file1": "file1 content",
}):
}) as base_tag:
image_id = subprocess.check_output(["podman", "inspect", "-f", "{{ .Id }}", base_tag],
universal_newlines=True).strip()
checksum = f"sha256:{image_id}"