summaryrefslogtreecommitdiff
path: root/test/test_unit_configure_paths.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_unit_configure_paths.py')
-rw-r--r--test/test_unit_configure_paths.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/test/test_unit_configure_paths.py b/test/test_unit_configure_paths.py
index 332277d..1a6fea9 100644
--- a/test/test_unit_configure_paths.py
+++ b/test/test_unit_configure_paths.py
@@ -2,19 +2,21 @@
import pytest
-ARCHIVE = 'files.gpg'
+ARCHIVE = 'archive'
BOOTSTRAP = 'bootstrap'
CONFIG = 'config'
ENCRYPT = 'encrypt'
HOME = '/testhome'
REPO = 'repo.git'
YDIR = '.config/yadm'
+YDATA = '.local/share/yadm'
@pytest.mark.parametrize(
'override, expect', [
(None, {}),
- ('-Y', {}),
+ ('-Y', {'yadm': 'YADM_DIR'}),
+ ('--yadm-data', {'data': 'YADM_DATA'}),
('--yadm-repo', {'repo': 'YADM_REPO', 'git': 'GIT_DIR'}),
('--yadm-config', {'config': 'YADM_CONFIG'}),
('--yadm-encrypt', {'encrypt': 'YADM_ENCRYPT'}),
@@ -23,6 +25,7 @@ YDIR = '.config/yadm'
], ids=[
'default',
'override yadm dir',
+ 'override yadm data',
'override repo',
'override config',
'override encrypt',
@@ -36,6 +39,8 @@ def test_config(runner, paths, override, expect):
args = []
if override == '-Y':
matches = match_map('/' + opath)
+ if override == '--yadm-data':
+ matches = match_map(None, '/' + opath)
if override:
args = [override, '/' + opath]
@@ -49,18 +54,20 @@ def test_config(runner, paths, override, expect):
run_test(runner, paths, args, matches.values(), 0)
-def match_map(yadm_dir=None):
+def match_map(yadm_dir=None, yadm_data=None):
"""Create a dictionary of matches, relative to yadm_dir"""
if not yadm_dir:
yadm_dir = '/'.join([HOME, YDIR])
+ if not yadm_data:
+ yadm_data = '/'.join([HOME, YDATA])
return {
'yadm': f'YADM_DIR="{yadm_dir}"',
- 'repo': f'YADM_REPO="{yadm_dir}/{REPO}"',
+ 'repo': f'YADM_REPO="{yadm_data}/{REPO}"',
'config': f'YADM_CONFIG="{yadm_dir}/{CONFIG}"',
'encrypt': f'YADM_ENCRYPT="{yadm_dir}/{ENCRYPT}"',
- 'archive': f'YADM_ARCHIVE="{yadm_dir}/{ARCHIVE}"',
+ 'archive': f'YADM_ARCHIVE="{yadm_data}/{ARCHIVE}"',
'bootstrap': f'YADM_BOOTSTRAP="{yadm_dir}/{BOOTSTRAP}"',
- 'git': f'GIT_DIR="{yadm_dir}/{REPO}"',
+ 'git': f'GIT_DIR="{yadm_data}/{REPO}"',
}
@@ -70,12 +77,15 @@ 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
+ XDG_CONFIG_HOME=
+ XDG_DATA_HOME=
+ HOME="{HOME}" set_yadm_dirs
configure_paths
declare -p | grep -E '(YADM|GIT)_'
"""
run = runner(command=['bash'], inp=script)
assert run.code == expected_code
- assert run.err == ''
+ assert run.success == (run.code == 0)
+ assert (run.err if run.success else run.out) == ''
for match in expected_matches:
- assert match in run.out
+ assert match in run.out if run.success else run.err