Add unit tests for reporting invalid alternates (#183)
This commit is contained in:
parent
59da359e63
commit
66a3969c8a
2 changed files with 55 additions and 0 deletions
39
test/test_unit_report_invalid_alts.py
Normal file
39
test/test_unit_report_invalid_alts.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
"""Unit tests: report_invalid_alts"""
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'condition', [
|
||||
'compat',
|
||||
'previous-message',
|
||||
'invalid-alts',
|
||||
'no-invalid-alts',
|
||||
])
|
||||
def test_report_invalid_alts(runner, yadm, condition):
|
||||
"""Use report_invalid_alts"""
|
||||
|
||||
compat = ''
|
||||
previous = ''
|
||||
alts = 'INVALID_ALT=()'
|
||||
if condition == 'compat':
|
||||
compat = 'YADM_COMPATIBILITY=1'
|
||||
if condition == 'previous-message':
|
||||
previous = 'LEGACY_WARNING_ISSUED=1'
|
||||
if condition == 'invalid-alts':
|
||||
alts = 'INVALID_ALT=("file##invalid")'
|
||||
|
||||
script = f"""
|
||||
YADM_TEST=1 source {yadm}
|
||||
{compat}
|
||||
{previous}
|
||||
{alts}
|
||||
report_invalid_alts
|
||||
"""
|
||||
run = runner(command=['bash'], inp=script)
|
||||
assert run.success
|
||||
assert run.err == ''
|
||||
if condition == 'invalid-alts':
|
||||
assert 'WARNING' in run.out
|
||||
assert 'file##invalid' in run.out
|
||||
else:
|
||||
assert run.out == ''
|
|
@ -260,3 +260,19 @@ def test_template_recording(runner, yadm, cmd_generated):
|
|||
assert run.success
|
||||
assert run.err == ''
|
||||
assert run.out.rstrip() == expected
|
||||
|
||||
|
||||
def test_invalid(runner, yadm):
|
||||
"""Verify invalid alternates are noted in INVALID_ALT"""
|
||||
|
||||
invalid_file = "file##invalid"
|
||||
|
||||
script = f"""
|
||||
YADM_TEST=1 source {yadm}
|
||||
score_file "{invalid_file}"
|
||||
echo "INVALID:${{INVALID_ALT[@]}}"
|
||||
"""
|
||||
run = runner(command=['bash'], inp=script)
|
||||
assert run.success
|
||||
assert run.err == ''
|
||||
assert run.out.rstrip() == f'INVALID:{invalid_file}'
|
||||
|
|
Loading…
Reference in a new issue