inputs: add inputs_service fixture
This new fixture avoids some repetitivness when building tests for input services.
This commit is contained in:
parent
5f31ccf9f2
commit
7c0e9cfcf7
2 changed files with 25 additions and 8 deletions
|
|
@ -7,7 +7,6 @@ import tempfile
|
|||
|
||||
import pytest
|
||||
|
||||
from osbuild import testutil
|
||||
from osbuild.testutil import has_executable, make_container
|
||||
|
||||
INPUTS_NAME = "org.osbuild.containers-storage"
|
||||
|
|
@ -26,7 +25,7 @@ class FakeStoreClient:
|
|||
|
||||
@pytest.mark.skipif(not has_executable("podman"), reason="no podman executable")
|
||||
@pytest.mark.skipif(os.getuid() != 0, reason="root only")
|
||||
def test_containers_local_inputs_integration(tmp_path, inputs_module):
|
||||
def test_containers_local_inputs_integration(tmp_path, inputs_service):
|
||||
with make_container(tmp_path, {"file1": "file1 content"}) as base_tag:
|
||||
image_id = subprocess.check_output(
|
||||
["podman", "inspect", "-f", "{{ .Id }}", base_tag],
|
||||
|
|
@ -40,8 +39,6 @@ def test_containers_local_inputs_integration(tmp_path, inputs_module):
|
|||
}
|
||||
}
|
||||
}
|
||||
fd = testutil.make_fake_service_fd()
|
||||
cnt_inputs = inputs_module.ContainersStorageInput.from_args(["--service-fd", str(fd)])
|
||||
store = FakeStoreClient(tmp_path / "fake-sources")
|
||||
# not using "tmp_path" here as it will "rm -rf" on cleanup and
|
||||
# that is dangerous as during the tests we bind mount the
|
||||
|
|
@ -49,12 +46,12 @@ def test_containers_local_inputs_integration(tmp_path, inputs_module):
|
|||
target = pathlib.Path(tempfile.TemporaryDirectory("cnt-target").name)
|
||||
options = None
|
||||
try:
|
||||
reply = cnt_inputs.map(store, inputs["origin"], inputs["references"], target, options)
|
||||
reply = inputs_service.map(store, inputs["origin"], inputs["references"], target, options)
|
||||
assert reply["path"] == target
|
||||
assert len(reply["data"]["archives"]) == 1
|
||||
assert (target / "storage").exists()
|
||||
finally:
|
||||
cnt_inputs.unmap()
|
||||
inputs_service.unmap()
|
||||
# cleanup manually, note that we only remove empty dirs here,
|
||||
# because we only expect a bind mount under "$target/storage"
|
||||
# Anything non-empty here means a umount() failed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue