sources: fix ostree_sources test to work without /var/empty
Not all distros ship `/var/empty` so just create an empty dir on demand as needed. This also tweaks `test_ostree_source_exists()` into calling `make_repo()` instead of duplicating that code.
This commit is contained in:
parent
9071cd0abb
commit
2f892b20e7
1 changed files with 7 additions and 5 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import tempfile
|
||||||
|
|
||||||
from osbuild.testutil.net import http_serve_directory, https_serve_directory
|
from osbuild.testutil.net import http_serve_directory, https_serve_directory
|
||||||
from osbuild.util import ostree
|
from osbuild.util import ostree
|
||||||
|
|
@ -16,9 +17,9 @@ def test_ostree_source_not_exists(tmp_path, sources_service):
|
||||||
|
|
||||||
def test_ostree_source_exists(tmp_path, sources_service):
|
def test_ostree_source_exists(tmp_path, sources_service):
|
||||||
sources_service.setup({"cache": tmp_path, "options": {}})
|
sources_service.setup({"cache": tmp_path, "options": {}})
|
||||||
repo = tmp_path / "org.osbuild.ostree" / "repo"
|
root = tmp_path / "org.osbuild.ostree" / "repo"
|
||||||
commit = ostree.cli("commit", f"--repo={repo}", "--orphan", "/var/empty")
|
commit = make_repo(root)
|
||||||
assert sources_service.exists("sha256:" + commit.stdout, None)
|
assert sources_service.exists("sha256:" + commit, None)
|
||||||
|
|
||||||
|
|
||||||
def make_test_sources(proto, port, fake_commit, **secrets):
|
def make_test_sources(proto, port, fake_commit, **secrets):
|
||||||
|
|
@ -35,8 +36,9 @@ def make_test_sources(proto, port, fake_commit, **secrets):
|
||||||
|
|
||||||
|
|
||||||
def make_repo(root):
|
def make_repo(root):
|
||||||
ostree.cli("init", f"--repo={root}")
|
with tempfile.TemporaryDirectory() as empty_tmpdir:
|
||||||
return ostree.cli("commit", f"--repo={root}", "--orphan", "/var/empty").stdout.rstrip()
|
ostree.cli("init", f"--repo={root}")
|
||||||
|
return ostree.cli("commit", f"--repo={root}", "--orphan", empty_tmpdir).stdout.rstrip()
|
||||||
|
|
||||||
|
|
||||||
def test_ostree_pull_plain(tmp_path, sources_service):
|
def test_ostree_pull_plain(tmp_path, sources_service):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue