1
0
Fork 0
mirror of synced 2024-11-16 06:15:34 -05:00
yadm/test/test_unit_private_dirs.py

35 lines
852 B
Python
Raw Normal View History

"""Unit tests: private_dirs"""
import pytest
@pytest.mark.parametrize(
2023-07-10 15:43:17 -04:00
"gnupghome",
[True, False],
2023-07-10 15:43:17 -04:00
ids=["gnupghome-set", "gnupghome-unset"],
)
2023-07-10 15:43:17 -04:00
@pytest.mark.parametrize("param", ["all", "gnupg"])
def test_relative_path(runner, paths, gnupghome, param):
"""Test translate_to_relative"""
2023-07-10 15:43:17 -04:00
alt_gnupghome = "alt/gnupghome"
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
2023-07-10 15:43:17 -04:00
expected = alt_gnupghome if gnupghome else ".gnupg"
if param == "all":
expected = f".ssh {expected}"
2023-07-10 15:43:17 -04:00
run = runner(command=["bash"], inp=script, env=env)
assert run.success
2023-07-10 15:43:17 -04:00
assert run.err == ""
assert run.out.strip() == expected