1
0
Fork 0
mirror of synced 2024-12-22 06:31:07 -05:00
yadm/test/test_unit_query_distro_family.py

26 lines
846 B
Python
Raw Normal View History

"""Unit tests: query_distro_family"""
import pytest
2023-07-10 15:43:17 -04:00
@pytest.mark.parametrize("condition", ["os-release", "os-release-quotes", "missing"])
def test_query_distro_family(runner, yadm, tmp_path, condition):
"""Match ID_LIKE when present"""
2023-07-10 15:43:17 -04:00
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")
script = f"""
YADM_TEST=1 source {yadm}
OS_RELEASE="{os_release}"
query_distro_family
"""
2023-07-10 15:43:17 -04:00
run = runner(command=["bash"], inp=script)
assert run.success
2023-07-10 15:43:17 -04:00
assert run.err == ""
if "os-release" in condition:
assert run.out.rstrip() == test_family
else:
2023-07-10 15:43:17 -04:00
assert run.out.rstrip() == ""