Unit tests: fix template test - override the input in the flake template

This commit is contained in:
Johannes Kirschbauer
2024-07-17 12:06:23 +02:00
parent fdd19b8ddd
commit ad70ee72e5
2 changed files with 20 additions and 0 deletions

View File

@@ -32,6 +32,10 @@ def substitute(
line = line.replace( line = line.replace(
"git+https://git.clan.lol/clan/clan-core", str(clan_core_flake) "git+https://git.clan.lol/clan/clan-core", str(clan_core_flake)
) )
line = line.replace(
"https://git.clan.lol/clan/clan-core/archive/main.tar.gz",
str(clan_core_flake),
)
line = line.replace("__CLAN_SOPS_KEY_PATH__", sops_key) line = line.replace("__CLAN_SOPS_KEY_PATH__", sops_key)
line = line.replace("__CLAN_SOPS_KEY_DIR__", str(flake)) line = line.replace("__CLAN_SOPS_KEY_DIR__", str(flake))
print(line, end="") print(line, end="")

View File

@@ -3,6 +3,7 @@ import subprocess
from pathlib import Path from pathlib import Path
import pytest import pytest
from fixtures_flakes import substitute
from helpers import cli from helpers import cli
@@ -17,7 +18,15 @@ def test_create_flake(
url = f"{clan_core}#default" url = f"{clan_core}#default"
cli.run(["flakes", "create", str(flake_dir), f"--url={url}"]) cli.run(["flakes", "create", str(flake_dir), f"--url={url}"])
assert (flake_dir / ".clan-flake").exists() assert (flake_dir / ".clan-flake").exists()
# Replace the inputs.clan.url in the template flake.nix
substitute(
flake_dir / "flake.nix",
clan_core,
)
monkeypatch.chdir(flake_dir) monkeypatch.chdir(flake_dir)
cli.run(["machines", "create", "machine1"]) cli.run(["machines", "create", "machine1"])
capsys.readouterr() # flush cache capsys.readouterr() # flush cache
@@ -55,6 +64,13 @@ def test_ui_template(
flake_dir = temporary_home / "test-flake" flake_dir = temporary_home / "test-flake"
url = f"{clan_core}#minimal" url = f"{clan_core}#minimal"
cli.run(["flakes", "create", str(flake_dir), f"--url={url}"]) cli.run(["flakes", "create", str(flake_dir), f"--url={url}"])
# Replace the inputs.clan.url in the template flake.nix
substitute(
flake_dir / "flake.nix",
clan_core,
)
monkeypatch.chdir(flake_dir) monkeypatch.chdir(flake_dir)
cli.run(["machines", "create", "machine1"]) cli.run(["machines", "create", "machine1"])
capsys.readouterr() # flush cache capsys.readouterr() # flush cache