2019-08-06 13:19:45 +00:00
|
|
|
"""Unit tests: issue_legacy_path_warning"""
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
'legacy_path', [
|
|
|
|
None,
|
|
|
|
'repo.git',
|
|
|
|
'files.gpg',
|
|
|
|
],
|
|
|
|
)
|
2020-11-18 05:01:45 +00:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
'override', [True, False], ids=['override', 'no-override'])
|
2019-10-22 22:47:41 +00:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
'upgrade', [True, False], ids=['upgrade', 'no-upgrade'])
|
2020-11-18 05:01:45 +00:00
|
|
|
def test_legacy_warning(tmpdir, runner, yadm, upgrade, override, legacy_path):
|
2019-08-06 13:19:45 +00:00
|
|
|
"""Use issue_legacy_path_warning"""
|
|
|
|
home = tmpdir.mkdir('home')
|
|
|
|
|
|
|
|
if legacy_path:
|
2020-11-18 05:01:45 +00:00
|
|
|
home.ensure(f'.config/yadm/{str(legacy_path)}')
|
2019-08-06 13:19:45 +00:00
|
|
|
|
2020-11-18 05:01:45 +00:00
|
|
|
override = 'YADM_OVERRIDE_REPO=override' if override else ''
|
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"""
|
2020-11-18 05:01:45 +00:00
|
|
|
XDG_CONFIG_HOME=
|
|
|
|
XDG_DATA_HOME=
|
2019-08-06 13:19:45 +00:00
|
|
|
HOME={home}
|
|
|
|
YADM_TEST=1 source {yadm}
|
2019-10-22 22:47:41 +00:00
|
|
|
{main_args}
|
2020-11-18 05:01:45 +00:00
|
|
|
{override}
|
|
|
|
set_yadm_dirs
|
2019-08-06 13:19:45 +00:00
|
|
|
issue_legacy_path_warning
|
|
|
|
"""
|
|
|
|
run = runner(command=['bash'], inp=script)
|
|
|
|
assert run.success
|
2020-12-27 21:22:32 +00:00
|
|
|
assert run.out == ''
|
2020-11-18 05:01:45 +00:00
|
|
|
if legacy_path and (not upgrade) and (not override):
|
2020-12-27 21:22:32 +00:00
|
|
|
assert 'Legacy paths have been detected' in run.err
|
2019-08-06 13:19:45 +00:00
|
|
|
else:
|
2020-12-27 21:22:32 +00:00
|
|
|
assert 'Legacy paths have been detected' not in run.err
|