|
|
@ -32,26 +32,30 @@ YDATA = '.local/share/yadm'
|
|
|
|
'override archive',
|
|
|
|
'override archive',
|
|
|
|
'override bootstrap',
|
|
|
|
'override bootstrap',
|
|
|
|
])
|
|
|
|
])
|
|
|
|
def test_config(runner, paths, override, expect):
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
|
|
|
'path', ['.', './override', 'override', '.override', '/override'], ids=[
|
|
|
|
|
|
|
|
'cwd', './relative', 'relative', 'hidden relative', 'absolute'
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
def test_config(runner, paths, override, expect, path):
|
|
|
|
"""Test configure_paths"""
|
|
|
|
"""Test configure_paths"""
|
|
|
|
opath = 'override'
|
|
|
|
if path.startswith('/'):
|
|
|
|
matches = match_map()
|
|
|
|
expected_path = path
|
|
|
|
args = []
|
|
|
|
else:
|
|
|
|
|
|
|
|
expected_path = str(paths.root.join(path))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args = [override, path] if override else []
|
|
|
|
|
|
|
|
|
|
|
|
if override == '-Y':
|
|
|
|
if override == '-Y':
|
|
|
|
matches = match_map('/' + opath)
|
|
|
|
matches = match_map(expected_path)
|
|
|
|
if override == '--yadm-data':
|
|
|
|
elif override == '--yadm-data':
|
|
|
|
matches = match_map(None, '/' + opath)
|
|
|
|
matches = match_map(None, expected_path)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
matches = match_map()
|
|
|
|
|
|
|
|
|
|
|
|
if override:
|
|
|
|
|
|
|
|
args = [override, '/' + opath]
|
|
|
|
|
|
|
|
for ekey in expect.keys():
|
|
|
|
for ekey in expect.keys():
|
|
|
|
matches[ekey] = f'{expect[ekey]}="/{opath}"'
|
|
|
|
matches[ekey] = f'{expect[ekey]}="{expected_path}"'
|
|
|
|
run_test(
|
|
|
|
|
|
|
|
runner, paths,
|
|
|
|
|
|
|
|
[override, opath],
|
|
|
|
|
|
|
|
['must specify a fully qualified'], 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
run_test(runner, paths, args, matches.values(), 0)
|
|
|
|
run_test(runner, paths, args, matches.values(), cwd=str(paths.root))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def match_map(yadm_dir=None, yadm_data=None):
|
|
|
|
def match_map(yadm_dir=None, yadm_data=None):
|
|
|
@ -71,7 +75,7 @@ def match_map(yadm_dir=None, yadm_data=None):
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_test(runner, paths, args, expected_matches, expected_code=0):
|
|
|
|
def run_test(runner, paths, args, expected_matches, cwd=None):
|
|
|
|
"""Run proces global args, and run configure_paths"""
|
|
|
|
"""Run proces global args, and run configure_paths"""
|
|
|
|
argstring = ' '.join(['"'+a+'"' for a in args])
|
|
|
|
argstring = ' '.join(['"'+a+'"' for a in args])
|
|
|
|
script = f"""
|
|
|
|
script = f"""
|
|
|
@ -83,9 +87,8 @@ def run_test(runner, paths, args, expected_matches, expected_code=0):
|
|
|
|
configure_paths
|
|
|
|
configure_paths
|
|
|
|
declare -p | grep -E '(YADM|GIT)_'
|
|
|
|
declare -p | grep -E '(YADM|GIT)_'
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
run = runner(command=['bash'], inp=script)
|
|
|
|
run = runner(command=['bash'], inp=script, cwd=cwd)
|
|
|
|
assert run.code == expected_code
|
|
|
|
assert run.success
|
|
|
|
assert run.success == (run.code == 0)
|
|
|
|
assert run.err == ''
|
|
|
|
assert (run.err if run.success else run.out) == ''
|
|
|
|
|
|
|
|
for match in expected_matches:
|
|
|
|
for match in expected_matches:
|
|
|
|
assert match in run.out if run.success else run.err
|
|
|
|
assert match in run.out
|
|
|
|