mirror of
https://github.com/TheLocehiliosan/yadm
synced 2026-03-02 03:49:29 +00:00
@@ -3,14 +3,16 @@
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize("condition", ["os-release", "os-release-quotes", "missing"])
|
||||
@pytest.mark.parametrize("condition", ["os-release", "os-release-quotes", "missing", "fallback"])
|
||||
def test_query_distro_family(runner, yadm, tmp_path, condition):
|
||||
"""Match ID_LIKE when present"""
|
||||
test_family = "testfamily"
|
||||
os_release = tmp_path.joinpath("os-release")
|
||||
if "os-release" in condition:
|
||||
quotes = '"' if "quotes" in condition else ""
|
||||
os_release.write_text(f"testing\nID_LIKE={quotes}{test_family}{quotes}\nfamily")
|
||||
os_release.write_text(f"testing\nID=test\nID_LIKE={quotes}{test_family}{quotes}\nfamily")
|
||||
elif condition == "fallback":
|
||||
os_release.write_text(f'testing\nID="{test_family}"\nfamily')
|
||||
script = f"""
|
||||
YADM_TEST=1 source {yadm}
|
||||
OS_RELEASE="{os_release}"
|
||||
@@ -19,7 +21,7 @@ def test_query_distro_family(runner, yadm, tmp_path, condition):
|
||||
run = runner(command=["bash"], inp=script)
|
||||
assert run.success
|
||||
assert run.err == ""
|
||||
if "os-release" in condition:
|
||||
assert run.out.rstrip() == test_family
|
||||
else:
|
||||
if condition == "missing":
|
||||
assert run.out.rstrip() == ""
|
||||
else:
|
||||
assert run.out.rstrip() == test_family
|
||||
|
||||
Reference in New Issue
Block a user