clan_lib: Add test for check_valid_clan function

This commit is contained in:
Qubasa
2025-07-10 14:20:02 +07:00
parent f8ecd4372e
commit dd12104e2f
2 changed files with 24 additions and 1 deletions

View File

@@ -71,8 +71,8 @@ def substitute(
with file.open() as f:
for line in f:
line = line.replace("__NIXPKGS__", str(nixpkgs_source()))
if clan_core_replacement:
line = line.replace("__NIXPKGS__", str(nixpkgs_source()))
line = line.replace("__CLAN_CORE__", clan_core_replacement)
line = line.replace(
"git+https://git.clan.lol/clan/clan-core", clan_core_replacement
@@ -385,6 +385,7 @@ def test_flake(
flake_template="test_flake",
monkeypatch=monkeypatch,
)
# check that git diff on ./sops is empty
if (temporary_home / "test_flake" / "sops").exists():
git_proc = sp.run(

View File

@@ -0,0 +1,22 @@
from pathlib import Path
from clan_cli.tests.fixtures_flakes import FlakeForTest
from clan_lib.clan.check import check_clan_valid
from clan_lib.flake import Flake
def test_check_clan_valid(
temporary_home: Path, test_flake_with_core: FlakeForTest, test_flake: FlakeForTest
) -> None:
# Test with a valid clan
flake = Flake(str(test_flake_with_core.path))
assert check_clan_valid(flake) is True
# Test with an invalid clan
flake = Flake(str(test_flake.path))
assert check_clan_valid(flake) is False
# Test with a non-existent clan
flake = Flake(str(temporary_home))
assert check_clan_valid(flake) is False