2023-07-28 10:10:07 +00:00
|
|
|
import os
|
2023-09-21 12:07:54 +00:00
|
|
|
import subprocess
|
2023-07-28 10:12:37 +00:00
|
|
|
import sys
|
2023-09-21 12:07:54 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from clan_cli.nix import nix_shell
|
2023-08-26 09:23:15 +00:00
|
|
|
|
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-10-06 16:52:56 +00:00
|
|
|
"fixtures_flakes",
|
2023-08-09 14:38:08 +00:00
|
|
|
]
|
2023-09-21 12:07:54 +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
|