2019-08-06 09:19:45 -04: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 18:47:41 -04:00
|
|
|
'hooks/pre_command',
|
|
|
|
'hooks/post_command',
|
2019-08-06 09:19:45 -04:00
|
|
|
],
|
|
|
|
)
|
2019-10-22 18:47:41 -04:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
'upgrade', [True, False], ids=['upgrade', 'no-upgrade'])
|
|
|
|
def test_legacy_warning(tmpdir, runner, yadm, upgrade, legacy_path):
|
2019-08-06 09:19:45 -04:00
|
|
|
"""Use issue_legacy_path_warning"""
|
|
|
|
home = tmpdir.mkdir('home')
|
|
|
|
|
|
|
|
if legacy_path:
|
2019-10-22 18:47:41 -04:00
|
|
|
home.mkdir(f'.yadm').ensure(legacy_path)
|
2019-08-06 09:19:45 -04:00
|
|
|
|
2019-10-22 18:47:41 -04:00
|
|
|
main_args = 'MAIN_ARGS=("upgrade")' if upgrade else ''
|
2019-08-06 09:19:45 -04:00
|
|
|
script = f"""
|
|
|
|
HOME={home}
|
|
|
|
YADM_TEST=1 source {yadm}
|
2019-10-22 18:47:41 -04:00
|
|
|
{main_args}
|
2019-08-06 09:19:45 -04:00
|
|
|
issue_legacy_path_warning
|
|
|
|
"""
|
|
|
|
run = runner(command=['bash'], inp=script)
|
|
|
|
assert run.success
|
|
|
|
assert run.err == ''
|
2019-10-22 18:47:41 -04:00
|
|
|
if legacy_path and not upgrade:
|
2019-08-06 09:19:45 -04:00
|
|
|
assert 'Legacy configuration paths have been detected' in run.out
|
|
|
|
else:
|
|
|
|
assert run.out.rstrip() == ''
|