From ad70ee72e5434f04c599df8659b2b98530a2ff03 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 17 Jul 2024 12:06:23 +0200 Subject: [PATCH] Unit tests: fix template test - override the input in the flake template --- pkgs/clan-cli/tests/fixtures_flakes.py | 4 ++++ pkgs/clan-cli/tests/test_create_flake.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/pkgs/clan-cli/tests/fixtures_flakes.py b/pkgs/clan-cli/tests/fixtures_flakes.py index 336112811..ea43d070d 100644 --- a/pkgs/clan-cli/tests/fixtures_flakes.py +++ b/pkgs/clan-cli/tests/fixtures_flakes.py @@ -32,6 +32,10 @@ def substitute( line = line.replace( "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_DIR__", str(flake)) print(line, end="") diff --git a/pkgs/clan-cli/tests/test_create_flake.py b/pkgs/clan-cli/tests/test_create_flake.py index ae09e79a6..db4c7c8ef 100644 --- a/pkgs/clan-cli/tests/test_create_flake.py +++ b/pkgs/clan-cli/tests/test_create_flake.py @@ -3,6 +3,7 @@ import subprocess from pathlib import Path import pytest +from fixtures_flakes import substitute from helpers import cli @@ -17,7 +18,15 @@ def test_create_flake( url = f"{clan_core}#default" cli.run(["flakes", "create", str(flake_dir), f"--url={url}"]) + 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) cli.run(["machines", "create", "machine1"]) capsys.readouterr() # flush cache @@ -55,6 +64,13 @@ def test_ui_template( flake_dir = temporary_home / "test-flake" url = f"{clan_core}#minimal" 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) cli.run(["machines", "create", "machine1"]) capsys.readouterr() # flush cache