clan-core/pkgs/clan-cli/tests/conftest.py

38 lines
899 B
Python
Raw Normal View History

import os
import subprocess
2023-07-28 10:12:37 +00:00
import sys
from pathlib import Path
import pytest
from clan_cli.nix import nix_shell
2023-07-28 10:12:37 +00:00
sys.path.append(os.path.join(os.path.dirname(__file__), "helpers"))
2023-08-09 14:38:08 +00:00
pytest_plugins = [
2023-08-24 17:16:44 +00:00
"api",
2023-08-09 14:38:08 +00:00
"temporary_dir",
"root",
"age_keys",
"sshd",
"command",
"ports",
2023-08-10 10:39:26 +00:00
"host_group",
2023-09-15 10:31:18 +00:00
"test_flake",
2023-08-09 14:38:08 +00:00
]
# 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