test: copied build_fake_container_fixture() from bib
This is a very sad commit, it copies the code to make a fake container with a faked osbuild. The bright side is that the plan is to rewrite these helpers in go and then we can just have a shared testutil module that can be imported from both bib/ibcli. And/or the two repos will merge and its just a (simple) test helper. But I do not feel good (at all) about this.
This commit is contained in:
parent
1198c73102
commit
9a0f2ee7d7
1 changed files with 37 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import subprocess
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -15,3 +16,39 @@ def build_container_fixture():
|
|||
"-t", container_tag,
|
||||
])
|
||||
return container_tag
|
||||
|
||||
|
||||
# XXX: copied from bib
|
||||
@pytest.fixture(name="build_fake_container", scope="session")
|
||||
def build_fake_container_fixture(tmpdir_factory, build_container):
|
||||
"""Build a container with a fake osbuild and returns the name"""
|
||||
tmp_path = tmpdir_factory.mktemp("build-fake-container")
|
||||
|
||||
fake_osbuild_path = tmp_path / "fake-osbuild"
|
||||
fake_osbuild_path.write_text(textwrap.dedent("""\
|
||||
#!/bin/bash -e
|
||||
|
||||
# injest generated manifest from the images library, if we do not
|
||||
# do this images may fail with "broken" pipe errors
|
||||
cat - >/dev/null
|
||||
|
||||
mkdir -p /output/qcow2
|
||||
echo "fake-disk.qcow2" > /output/qcow2/disk.qcow2
|
||||
|
||||
"""), encoding="utf8")
|
||||
|
||||
cntf_path = tmp_path / "Containerfile"
|
||||
|
||||
cntf_path.write_text(textwrap.dedent(f"""\n
|
||||
FROM {build_container}
|
||||
COPY fake-osbuild /usr/bin/osbuild
|
||||
RUN chmod 755 /usr/bin/osbuild
|
||||
"""), encoding="utf8")
|
||||
|
||||
container_tag = "bootc-image-builder-test-faked-osbuild"
|
||||
subprocess.check_call([
|
||||
"podman", "build",
|
||||
"-t", container_tag,
|
||||
tmp_path,
|
||||
])
|
||||
return container_tag
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue