https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.htmlpull/174/head
parent
f0ad40376d
commit
48fc6b0db7
@ -0,0 +1,34 @@
|
|||||||
|
"""Unit tests: issue_legacy_path_warning"""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'legacy_path', [
|
||||||
|
None,
|
||||||
|
'repo.git',
|
||||||
|
'config',
|
||||||
|
'encrypt',
|
||||||
|
'files.gpg',
|
||||||
|
'bootstrap',
|
||||||
|
'hooks',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_legacy_warning(tmpdir, runner, yadm, legacy_path):
|
||||||
|
"""Use issue_legacy_path_warning"""
|
||||||
|
home = tmpdir.mkdir('home')
|
||||||
|
|
||||||
|
if legacy_path:
|
||||||
|
home.mkdir(f'.yadm').mkdir(legacy_path)
|
||||||
|
|
||||||
|
script = f"""
|
||||||
|
HOME={home}
|
||||||
|
YADM_TEST=1 source {yadm}
|
||||||
|
issue_legacy_path_warning
|
||||||
|
"""
|
||||||
|
run = runner(command=['bash'], inp=script)
|
||||||
|
assert run.success
|
||||||
|
assert run.err == ''
|
||||||
|
if legacy_path:
|
||||||
|
assert 'Legacy configuration paths have been detected' in run.out
|
||||||
|
else:
|
||||||
|
assert run.out.rstrip() == ''
|
@ -0,0 +1,35 @@
|
|||||||
|
"""Unit tests: set_yadm_dir"""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'condition',
|
||||||
|
['basic', 'override', 'xdg_config_home', 'legacy'],
|
||||||
|
)
|
||||||
|
def test_set_yadm_dir(runner, yadm, condition):
|
||||||
|
"""Test set_yadm_dir"""
|
||||||
|
setup = ''
|
||||||
|
if condition == 'override':
|
||||||
|
setup = 'YADM_DIR=/override'
|
||||||
|
elif condition == 'xdg_config_home':
|
||||||
|
setup = 'XDG_CONFIG_HOME=/xdg'
|
||||||
|
elif condition == 'legacy':
|
||||||
|
setup = 'YADM_COMPATIBILITY=1'
|
||||||
|
script = f"""
|
||||||
|
HOME=/testhome
|
||||||
|
YADM_TEST=1 source {yadm}
|
||||||
|
{setup}
|
||||||
|
set_yadm_dir
|
||||||
|
echo "$YADM_DIR"
|
||||||
|
"""
|
||||||
|
run = runner(command=['bash'], inp=script)
|
||||||
|
assert run.success
|
||||||
|
assert run.err == ''
|
||||||
|
if condition == 'basic':
|
||||||
|
assert run.out.rstrip() == '/testhome/.config/yadm'
|
||||||
|
elif condition == 'override':
|
||||||
|
assert run.out.rstrip() == '/override'
|
||||||
|
elif condition == 'xdg_config_home':
|
||||||
|
assert run.out.rstrip() == '/xdg/yadm'
|
||||||
|
elif condition == 'legacy':
|
||||||
|
assert run.out.rstrip() == '/testhome/.yadm'
|
Loading…
Reference in new issue