sources: skip ostree tests if no ostree binary if found

This commit skips the ostree tests if no ostree binary is available.
This commit is contained in:
Michael Vogt 2024-11-26 16:15:19 +01:00
parent bca7fb1418
commit add78e7f47

View file

@ -3,18 +3,23 @@
import pathlib
import tempfile
import pytest
from osbuild.testutil import has_executable
from osbuild.testutil.net import http_serve_directory, https_serve_directory
from osbuild.util import ostree
SOURCES_NAME = "org.osbuild.ostree"
@pytest.mark.skipif(not has_executable("ostree"), reason="need ostree")
def test_ostree_source_not_exists(tmp_path, sources_service):
checksum = "sha256:1111111111111111111111111111111111111111111111111111111111111111"
sources_service.setup({"cache": tmp_path, "options": {}})
assert not sources_service.exists(checksum, None)
@pytest.mark.skipif(not has_executable("ostree"), reason="need ostree")
def test_ostree_source_exists(tmp_path, sources_service):
sources_service.setup({"cache": tmp_path, "options": {}})
root = tmp_path / "org.osbuild.ostree" / "repo"
@ -41,6 +46,7 @@ def make_repo(root):
return ostree.cli("commit", f"--repo={root}", "--orphan", empty_tmpdir).stdout.rstrip()
@pytest.mark.skipif(not has_executable("ostree"), reason="need ostree")
def test_ostree_pull_plain(tmp_path, sources_service):
fake_httpd_root = tmp_path / "fake-httpd-root"
fake_httpd_root.mkdir(exist_ok=True)
@ -53,6 +59,7 @@ def test_ostree_pull_plain(tmp_path, sources_service):
assert sources_service.exists("sha256:" + fake_commit, None)
@pytest.mark.skipif(not has_executable("ostree"), reason="need ostree")
def test_ostree_pull_plain_mtls(tmp_path, sources_service, monkeypatch):
fake_httpd_root = tmp_path / "fake-httpd-root"
fake_httpd_root.mkdir(exist_ok=True)