Add test for quoted os-release
This commit is contained in:
parent
4546636336
commit
d9f68978fa
1 changed files with 6 additions and 4 deletions
|
@ -3,14 +3,16 @@ import pytest
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'condition', ['lsb_release', 'os-release', 'missing'])
|
'condition', ['lsb_release', 'os-release', 'os-release-quotes', 'missing'])
|
||||||
def test_query_distro(runner, yadm, tst_distro, tmp_path, condition):
|
def test_query_distro(runner, yadm, tst_distro, tmp_path, condition):
|
||||||
"""Match lsb_release -si when present"""
|
"""Match lsb_release -si when present"""
|
||||||
test_release = 'testrelease'
|
test_release = 'testrelease'
|
||||||
lsb_release = ''
|
lsb_release = ''
|
||||||
os_release = tmp_path.joinpath('os-release')
|
os_release = tmp_path.joinpath('os-release')
|
||||||
if condition == 'os-release':
|
if 'os-release' in condition:
|
||||||
os_release.write_text(f"testing\nID={test_release}\nrelease")
|
quotes = '"' if 'quotes' in condition else ''
|
||||||
|
os_release.write_text(
|
||||||
|
f"testing\nID={quotes}{test_release}{quotes}\nrelease")
|
||||||
if condition != 'lsb_release':
|
if condition != 'lsb_release':
|
||||||
lsb_release = 'LSB_RELEASE_PROGRAM="missing_lsb_release"'
|
lsb_release = 'LSB_RELEASE_PROGRAM="missing_lsb_release"'
|
||||||
script = f"""
|
script = f"""
|
||||||
|
@ -24,7 +26,7 @@ def test_query_distro(runner, yadm, tst_distro, tmp_path, condition):
|
||||||
assert run.err == ''
|
assert run.err == ''
|
||||||
if condition == 'lsb_release':
|
if condition == 'lsb_release':
|
||||||
assert run.out.rstrip() == tst_distro
|
assert run.out.rstrip() == tst_distro
|
||||||
elif condition == 'os-release':
|
elif 'os-release' in condition:
|
||||||
assert run.out.rstrip() == test_release
|
assert run.out.rstrip() == test_release
|
||||||
else:
|
else:
|
||||||
assert run.out.rstrip() == ''
|
assert run.out.rstrip() == ''
|
||||||
|
|
Loading…
Reference in a new issue