stages: fix test values for "images" inputs

The "images" inputs in the tests were bad test values and only worked
"by accident" [0]. Thanks to Achilleas for discovering this!

This commit fixes this.

[0] https://github.com/osbuild/osbuild/pull/1752#discussion_r1580891435
This commit is contained in:
Michael Vogt 2024-04-26 15:16:32 +02:00 committed by Achilleas Koutsou
parent bd8f361851
commit d50857e5aa
4 changed files with 29 additions and 54 deletions

View file

@ -183,3 +183,21 @@ def find_one_subclass_in_module(module: ModuleType, subclass: Type) -> object:
raise ValueError(f"already have {cls}, also found {name}:{memb}")
cls = memb
return cls
def make_fake_images_inputs(fake_oci_path, name):
fname = fake_oci_path.name
dirname = fake_oci_path.parent
return {
"images": {
"path": dirname,
"data": {
"archives": {
fname: {
"format": "oci-archive",
"name": name,
},
},
},
},
}

View file

@ -31,7 +31,7 @@ FAKE_INPUTS = {
"path": "/input/images/path",
"data": {
"archives": {
"/input/images/path": {
"filename": {
"format": "oci-archive",
"name": "some-img-name",
},
@ -69,7 +69,7 @@ def test_bootc_install_to_fs(mock_run, mocked_named_tmp, mocked_temp_dir, stage_
"path": "/input/images/path",
"data": {
"archives": {
"/input/images/path": {
"filename": {
"format": "oci-archive",
"name": "some-img-name",
},

View file

@ -9,7 +9,7 @@ from unittest.mock import call, patch
import pytest
import osbuild.testutil
from osbuild.testutil import has_executable, make_container
from osbuild.testutil import has_executable, make_container, make_fake_images_inputs
STAGE_NAME = "org.osbuild.container-deploy"
@ -22,28 +22,15 @@ def test_container_deploy_integration(tmp_path, stage_module):
with make_container(tmp_path, {"file1": "file1 from base"}) as base_tag:
with make_container(tmp_path, {"file1": "file1 from final layer"}, base_tag) as cont_tag:
# export for the container-deploy stage
fake_container_dst = tmp_path / "fake-container"
fake_oci_path = tmp_path / "fake-container"
subprocess.check_call([
"podman", "save",
"--format=oci-archive",
f"--output={fake_container_dst}",
f"--output={fake_oci_path}",
cont_tag,
])
inputs = {
"images": {
# seems to be unused with fake_container_path?
"path": fake_container_dst,
"data": {
"archives": {
fake_container_dst: {
"format": "oci-archive",
"name": cont_tag,
},
},
},
},
}
inputs = make_fake_images_inputs(fake_oci_path, "some-name")
output_dir = tmp_path / "output"
options = {}
@ -66,28 +53,15 @@ def test_container_deploy_exclude(tmp_path, stage_module):
"dir2/file4": "dir2/file4 content",
}) as base_tag:
# export for the container-deploy stage
fake_container_dst = tmp_path / "fake-container"
fake_oci_path = tmp_path / "fake-container"
subprocess.check_call([
"podman", "save",
"--format=oci-archive",
f"--output={fake_container_dst}",
f"--output={fake_oci_path}",
base_tag,
])
inputs = {
"images": {
# seems to be unused with fake_container_path?
"path": fake_container_dst,
"data": {
"archives": {
fake_container_dst: {
"format": "oci-archive",
"name": base_tag,
},
},
},
},
}
inputs = make_fake_images_inputs(fake_oci_path, "some-name")
options = {
"exclude": [
"file2",

View file

@ -7,7 +7,7 @@ import tarfile
import pytest
from osbuild import testutil
from osbuild.testutil import has_executable, make_container
from osbuild.testutil import has_executable, make_container, make_fake_images_inputs
STAGE_NAME = "org.osbuild.skopeo"
@ -60,23 +60,6 @@ def make_fake_oci_archive(tmp_path):
return fake_container_dst
def make_skopeo_copy_inputs(fake_oci_path, name):
return {
"images": {
# seems to be unused with fake_container_path?
"path": fake_oci_path,
"data": {
"archives": {
fake_oci_path: {
"format": "oci-archive",
"name": name,
},
},
},
},
}
def assert_manifest_file(manifest_file):
assert manifest_file.exists()
data = json.loads(manifest_file.read_bytes())
@ -88,7 +71,7 @@ def assert_manifest_file(manifest_file):
def _test_skopeo_copy(tmp_path, stage_module, typ, dest_name):
fake_oci_path = make_fake_oci_archive(tmp_path)
inputs = make_skopeo_copy_inputs(fake_oci_path, "some-name")
inputs = make_fake_images_inputs(fake_oci_path, "some-name")
output_dir = tmp_path / "output"
local_path = f"/some/{dest_name}"