1
0
Fork 0
mirror of synced 2024-11-04 17:08:56 -05:00

Add unit tests for reporting invalid alternates (#183)

This commit is contained in:
Tim Byrne 2019-12-04 08:40:05 -06:00
parent 59da359e63
commit 66a3969c8a
No known key found for this signature in database
GPG key ID: 14DB4FC2465A4B12
2 changed files with 55 additions and 0 deletions

View 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 == ''

View file

@ -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}'