clan-cli: temporary_home, set XDG_RUNTIME_DIR #1571
@ -17,12 +17,20 @@ def temporary_home(monkeypatch: pytest.MonkeyPatch) -> Iterator[Path]:
|
|||||||
log.debug("Temp HOME directory: %s", str(path))
|
log.debug("Temp HOME directory: %s", str(path))
|
||||||
monkeypatch.setenv("HOME", str(path))
|
monkeypatch.setenv("HOME", str(path))
|
||||||
monkeypatch.setenv("XDG_CONFIG_HOME", str(path / ".config"))
|
monkeypatch.setenv("XDG_CONFIG_HOME", str(path / ".config"))
|
||||||
|
runtime_dir = path / "xdg-runtime-dir"
|
||||||
|
runtime_dir.mkdir()
|
||||||
|
runtime_dir.chmod(0o700)
|
||||||
|
monkeypatch.setenv("XDG_RUNTIME_DIR", str(runtime_dir))
|
||||||
monkeypatch.chdir(str(path))
|
monkeypatch.chdir(str(path))
|
||||||
yield path
|
yield path
|
||||||
else:
|
else:
|
||||||
with tempfile.TemporaryDirectory(prefix="pytest-") as dirpath:
|
with tempfile.TemporaryDirectory(prefix="pytest-") as dirpath:
|
||||||
monkeypatch.setenv("HOME", str(dirpath))
|
monkeypatch.setenv("HOME", str(dirpath))
|
||||||
monkeypatch.setenv("XDG_CONFIG_HOME", str(Path(dirpath) / ".config"))
|
monkeypatch.setenv("XDG_CONFIG_HOME", str(Path(dirpath) / ".config"))
|
||||||
|
runtime_dir = Path(dirpath) / "xdg-runtime-dir"
|
||||||
|
runtime_dir.mkdir()
|
||||||
|
runtime_dir.chmod(0o700)
|
||||||
|
monkeypatch.setenv("XDG_RUNTIME_DIR", str(runtime_dir))
|
||||||
monkeypatch.chdir(str(dirpath))
|
monkeypatch.chdir(str(dirpath))
|
||||||
log.debug("Temp HOME directory: %s", str(dirpath))
|
log.debug("Temp HOME directory: %s", str(dirpath))
|
||||||
yield Path(dirpath)
|
yield Path(dirpath)
|
||||||
|
@ -56,7 +56,6 @@ def test_upload_secret(
|
|||||||
# test idempotency
|
# test idempotency
|
||||||
cli.run(["facts", "generate", "vm1"])
|
cli.run(["facts", "generate", "vm1"])
|
||||||
assert identity_secret.lstat().st_mtime_ns == secret1_mtime
|
assert identity_secret.lstat().st_mtime_ns == secret1_mtime
|
||||||
|
|
||||||
flake = test_flake_with_core_and_pass.path.joinpath("flake.nix")
|
flake = test_flake_with_core_and_pass.path.joinpath("flake.nix")
|
||||||
host = host_group.hosts[0]
|
host = host_group.hosts[0]
|
||||||
addr = f"{host.user}@{host.host}:{host.port}?StrictHostKeyChecking=no&UserKnownHostsFile=/dev/null&IdentityFile={host.key}"
|
addr = f"{host.user}@{host.host}:{host.port}?StrictHostKeyChecking=no&UserKnownHostsFile=/dev/null&IdentityFile={host.key}"
|
||||||
|
Loading…
Reference in New Issue
Block a user