mirror of
https://github.com/TheLocehiliosan/yadm
synced 2026-03-02 03:49:29 +00:00
Support XDG base directory specification
https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
This commit is contained in:
@@ -8,7 +8,7 @@ CONFIG = 'config'
|
||||
ENCRYPT = 'encrypt'
|
||||
HOME = '/testhome'
|
||||
REPO = 'repo.git'
|
||||
YDIR = '.yadm'
|
||||
YDIR = '.config/yadm'
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -70,6 +70,7 @@ def run_test(runner, paths, args, expected_matches, expected_code=0):
|
||||
script = f"""
|
||||
YADM_TEST=1 HOME="{HOME}" source {paths.pgm}
|
||||
process_global_args {argstring}
|
||||
HOME="{HOME}" set_yadm_dir
|
||||
configure_paths
|
||||
declare -p | grep -E '(YADM|GIT)_'
|
||||
"""
|
||||
|
||||
34
test/test_unit_issue_legacy_path_warning.py
Normal file
34
test/test_unit_issue_legacy_path_warning.py
Normal file
@@ -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() == ''
|
||||
35
test/test_unit_set_yadm_dir.py
Normal file
35
test/test_unit_set_yadm_dir.py
Normal file
@@ -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'
|
||||
Reference in New Issue
Block a user