1
0
Fork 0
mirror of synced 2024-11-17 06:45:33 -05:00
yadm/test/test_unit_issue_legacy_path_warning.py

41 lines
1.2 KiB
Python
Raw Permalink Normal View History

"""Unit tests: issue_legacy_path_warning"""
import pytest
@pytest.mark.parametrize(
2023-07-10 15:43:17 -04:00
"legacy_path",
[
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"])
def test_legacy_warning(tmpdir, runner, yadm, upgrade, override, legacy_path):
"""Use issue_legacy_path_warning"""
2023-07-10 15:43:17 -04:00
home = tmpdir.mkdir("home")
if legacy_path:
2023-07-10 15:43:17 -04:00
home.ensure(f".config/yadm/{str(legacy_path)}")
2023-07-10 15:43:17 -04:00
override = "YADM_OVERRIDE_REPO=override" if override else ""
main_args = 'MAIN_ARGS=("upgrade")' if upgrade else ""
script = f"""
XDG_CONFIG_HOME=
XDG_DATA_HOME=
HOME={home}
YADM_TEST=1 source {yadm}
{main_args}
{override}
set_yadm_dirs
issue_legacy_path_warning
"""
2023-07-10 15:43:17 -04:00
run = runner(command=["bash"], inp=script)
assert run.success
2023-07-10 15:43:17 -04:00
assert run.out == ""
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
else:
2023-07-10 15:43:17 -04:00
assert "Legacy paths have been detected" not in run.err