2019-12-13 09:37:34 -05:00
|
|
|
"""Unit tests: private_dirs"""
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
2023-07-10 15:43:17 -04:00
|
|
|
"gnupghome",
|
2019-12-13 09:37:34 -05:00
|
|
|
[True, False],
|
2023-07-10 15:43:17 -04:00
|
|
|
ids=["gnupghome-set", "gnupghome-unset"],
|
2019-12-13 09:37:34 -05:00
|
|
|
)
|
2023-07-10 15:43:17 -04:00
|
|
|
@pytest.mark.parametrize("param", ["all", "gnupg"])
|
2019-12-13 09:37:34 -05:00
|
|
|
def test_relative_path(runner, paths, gnupghome, param):
|
|
|
|
"""Test translate_to_relative"""
|
|
|
|
|
2023-07-10 15:43:17 -04:00
|
|
|
alt_gnupghome = "alt/gnupghome"
|
2019-12-13 09:37:34 -05:00
|
|
|
env_gnupghome = paths.work.join(alt_gnupghome)
|
|
|
|
|
|
|
|
script = f"""
|
|
|
|
YADM_TEST=1 source {paths.pgm}
|
|
|
|
YADM_WORK={paths.work}
|
|
|
|
private_dirs {param}
|
|
|
|
"""
|
|
|
|
|
|
|
|
env = {}
|
|
|
|
if gnupghome:
|
2023-07-10 15:43:17 -04:00
|
|
|
env["GNUPGHOME"] = env_gnupghome
|
2019-12-13 09:37:34 -05:00
|
|
|
|
2023-07-10 15:43:17 -04:00
|
|
|
expected = alt_gnupghome if gnupghome else ".gnupg"
|
|
|
|
if param == "all":
|
|
|
|
expected = f".ssh {expected}"
|
2019-12-13 09:37:34 -05:00
|
|
|
|
2023-07-10 15:43:17 -04:00
|
|
|
run = runner(command=["bash"], inp=script, env=env)
|
2019-12-13 09:37:34 -05:00
|
|
|
assert run.success
|
2023-07-10 15:43:17 -04:00
|
|
|
assert run.err == ""
|
2019-12-13 09:37:34 -05:00
|
|
|
assert run.out.strip() == expected
|