2019-08-06 13:19:45 +00:00
|
|
|
"""Unit tests: issue_legacy_path_warning"""
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
'legacy_path', [
|
|
|
|
None,
|
|
|
|
'repo.git',
|
|
|
|
'config',
|
|
|
|
'encrypt',
|
|
|
|
'files.gpg',
|
|
|
|
'bootstrap',
|
2019-10-22 22:47:41 +00:00
|
|
|
'hooks/pre_command',
|
|
|
|
'hooks/post_command',
|
2019-08-06 13:19:45 +00:00
|
|
|
],
|
|
|
|
)
|
2019-10-22 22:47:41 +00:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
'upgrade', [True, False], ids=['upgrade', 'no-upgrade'])
|
|
|
|
def test_legacy_warning(tmpdir, runner, yadm, upgrade, legacy_path):
|
2019-08-06 13:19:45 +00:00
|
|
|
"""Use issue_legacy_path_warning"""
|
|
|
|
home = tmpdir.mkdir('home')
|
|
|
|
|
|
|
|
if legacy_path:
|
2019-10-22 22:47:41 +00:00
|
|
|
home.mkdir(f'.yadm').ensure(legacy_path)
|
2019-08-06 13:19:45 +00:00
|
|
|
|
2019-10-22 22:47:41 +00:00
|
|
|
main_args = 'MAIN_ARGS=("upgrade")' if upgrade else ''
|
2019-08-06 13:19:45 +00:00
|
|
|
script = f"""
|
|
|
|
HOME={home}
|
|
|
|
YADM_TEST=1 source {yadm}
|
2019-10-22 22:47:41 +00:00
|
|
|
{main_args}
|
2019-08-06 13:19:45 +00:00
|
|
|
issue_legacy_path_warning
|
2019-12-04 14:43:22 +00:00
|
|
|
echo "LWI:$LEGACY_WARNING_ISSUED"
|
2019-08-06 13:19:45 +00:00
|
|
|
"""
|
|
|
|
run = runner(command=['bash'], inp=script)
|
|
|
|
assert run.success
|
|
|
|
assert run.err == ''
|
2019-10-22 22:47:41 +00:00
|
|
|
if legacy_path and not upgrade:
|
2019-08-06 13:19:45 +00:00
|
|
|
assert 'Legacy configuration paths have been detected' in run.out
|
2019-12-04 14:43:22 +00:00
|
|
|
assert 'LWI:1' in run.out
|
2019-08-06 13:19:45 +00:00
|
|
|
else:
|
2019-12-04 14:43:22 +00:00
|
|
|
assert run.out.rstrip() == 'LWI:0'
|