clan-cli: temporary_home, set XDG_RUNTIME_DIR #1571

Merged
clan-bot merged 1 commits from Qubasa/clan-core:Qubasa-main into main 2024-06-05 11:39:14 +00:00
2 changed files with 8 additions and 1 deletions

View File

@ -17,12 +17,20 @@ def temporary_home(monkeypatch: pytest.MonkeyPatch) -> Iterator[Path]:
log.debug("Temp HOME directory: %s", str(path))
monkeypatch.setenv("HOME", str(path))
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))
yield path
else:
with tempfile.TemporaryDirectory(prefix="pytest-") as dirpath:
monkeypatch.setenv("HOME", str(dirpath))
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))
log.debug("Temp HOME directory: %s", str(dirpath))
yield Path(dirpath)

View File

@ -56,7 +56,6 @@ def test_upload_secret(
# test idempotency
cli.run(["facts", "generate", "vm1"])
assert identity_secret.lstat().st_mtime_ns == secret1_mtime
flake = test_flake_with_core_and_pass.path.joinpath("flake.nix")
host = host_group.hosts[0]
addr = f"{host.user}@{host.host}:{host.port}?StrictHostKeyChecking=no&UserKnownHostsFile=/dev/null&IdentityFile={host.key}"