clan-core/pkgs/clan-cli/tests/conftest.py
DavHau ceb6bdd474
All checks were successful
checks-impure / test (pull_request) Successful in 34s
checks / test (pull_request) Successful in 1m33s
clan join: test create vm for clan join
This adds a vm create test for the `clan join` scenario where:
  - there is no local clan to write changes to
  - a machine from a remote flake needs to be built and run
  - no users and no secrets need to be or can be managed (no flake to write files to)
2023-10-06 19:15:25 +02:00

38 lines
904 B
Python

import os
import subprocess
import sys
from pathlib import Path
import pytest
from clan_cli.nix import nix_shell
sys.path.append(os.path.join(os.path.dirname(__file__), "helpers"))
pytest_plugins = [
"api",
"temporary_dir",
"root",
"age_keys",
"sshd",
"command",
"ports",
"host_group",
"fixtures_flakes",
]
# fixture for git_repo
@pytest.fixture
def git_repo(tmp_path: Path) -> Path:
# initialize a git repository
cmd = nix_shell(["git"], ["git", "init"])
subprocess.run(cmd, cwd=tmp_path, check=True)
# set user.name and user.email
cmd = nix_shell(["git"], ["git", "config", "user.name", "test"])
subprocess.run(cmd, cwd=tmp_path, check=True)
cmd = nix_shell(["git"], ["git", "config", "user.email", "test@test.test"])
subprocess.run(cmd, cwd=tmp_path, check=True)
# return the path to the git repository
return tmp_path