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