test_vars_deployment: set hostPlatform depending on current system
This commit is contained in:
@@ -15,6 +15,7 @@ pytest_plugins = [
|
|||||||
"host_group",
|
"host_group",
|
||||||
"fixtures_flakes",
|
"fixtures_flakes",
|
||||||
"stdout",
|
"stdout",
|
||||||
|
"nix_config",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
24
pkgs/clan-cli/tests/nix_config.py
Normal file
24
pkgs/clan-cli/tests/nix_config.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import json
|
||||||
|
import subprocess
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ConfigItem:
|
||||||
|
aliases: list[str]
|
||||||
|
defaultValue: bool # noqa: N815
|
||||||
|
description: str
|
||||||
|
documentDefault: bool # noqa: N815
|
||||||
|
experimentalFeature: str # noqa: N815
|
||||||
|
value: str | bool | list[str] | dict[str, str]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def nix_config() -> dict[str, ConfigItem]:
|
||||||
|
proc = subprocess.run(
|
||||||
|
["nix", "show-config", "--json"], check=True, stdout=subprocess.PIPE
|
||||||
|
)
|
||||||
|
data = json.loads(proc.stdout)
|
||||||
|
return {name: ConfigItem(**c) for name, c in data.items()}
|
||||||
@@ -12,6 +12,7 @@ from clan_cli.vms.run import inspect_vm, spawn_vm
|
|||||||
from fixtures_flakes import generate_flake
|
from fixtures_flakes import generate_flake
|
||||||
from helpers import cli
|
from helpers import cli
|
||||||
from helpers.nixos_config import nested_dict
|
from helpers.nixos_config import nested_dict
|
||||||
|
from nix_config import ConfigItem
|
||||||
from root import CLAN_CORE
|
from root import CLAN_CORE
|
||||||
|
|
||||||
|
|
||||||
@@ -19,11 +20,12 @@ from root import CLAN_CORE
|
|||||||
def test_vm_deployment(
|
def test_vm_deployment(
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
temporary_home: Path,
|
temporary_home: Path,
|
||||||
|
nix_config: dict[str, ConfigItem],
|
||||||
sops_setup: SopsSetup,
|
sops_setup: SopsSetup,
|
||||||
) -> None:
|
) -> None:
|
||||||
# machine 1
|
# machine 1
|
||||||
machine1_config = nested_dict()
|
machine1_config = nested_dict()
|
||||||
machine1_config["nixpkgs"]["hostPlatform"] = "x86_64-linux"
|
machine1_config["nixpkgs"]["hostPlatform"] = nix_config["system"].value
|
||||||
machine1_config["clan"]["virtualisation"]["graphics"] = False
|
machine1_config["clan"]["virtualisation"]["graphics"] = False
|
||||||
machine1_config["services"]["getty"]["autologinUser"] = "root"
|
machine1_config["services"]["getty"]["autologinUser"] = "root"
|
||||||
machine1_config["services"]["openssh"]["enable"] = True
|
machine1_config["services"]["openssh"]["enable"] = True
|
||||||
@@ -49,6 +51,7 @@ def test_vm_deployment(
|
|||||||
"""
|
"""
|
||||||
# machine 2
|
# machine 2
|
||||||
machine2_config = nested_dict()
|
machine2_config = nested_dict()
|
||||||
|
machine2_config["nixpkgs"]["hostPlatform"] = nix_config["system"].value
|
||||||
machine2_config["clan"]["virtualisation"]["graphics"] = False
|
machine2_config["clan"]["virtualisation"]["graphics"] = False
|
||||||
machine2_config["services"]["getty"]["autologinUser"] = "root"
|
machine2_config["services"]["getty"]["autologinUser"] = "root"
|
||||||
machine2_config["services"]["openssh"]["enable"] = True
|
machine2_config["services"]["openssh"]["enable"] = True
|
||||||
|
|||||||
Reference in New Issue
Block a user