Added clan flakes inspect command. Improved ClanURI. Added democlan as dependency in flake.nix
This commit is contained in:
@@ -118,6 +118,24 @@ def test_flake_with_core(
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_local_democlan(
|
||||
monkeypatch: pytest.MonkeyPatch, temporary_home: Path
|
||||
) -> Iterator[FlakeForTest]:
|
||||
democlan = os.getenv(key="DEMOCLAN_ROOT")
|
||||
if democlan is None:
|
||||
raise Exception(
|
||||
"DEMOCLAN_ROOT not set. This test requires the democlan flake to be present"
|
||||
)
|
||||
democlan_p = Path(democlan).resolve()
|
||||
if not democlan_p.is_dir():
|
||||
raise Exception(
|
||||
f"DEMOCLAN_ROOT ({democlan_p}) is not a directory. This test requires the democlan directory to be present"
|
||||
)
|
||||
|
||||
yield FlakeForTest(democlan_p)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_democlan_url(
|
||||
monkeypatch: pytest.MonkeyPatch, temporary_home: Path
|
||||
|
||||
@@ -6,6 +6,21 @@ from clan_cli.clan_uri import ClanParameters, ClanScheme, ClanURI
|
||||
from clan_cli.errors import ClanError
|
||||
|
||||
|
||||
def test_get_internal() -> None:
|
||||
# Create a ClanURI object from a remote URI with parameters
|
||||
uri = ClanURI("clan://https://example.com?flake_attr=myVM&password=1234")
|
||||
assert uri.get_internal() == "https://example.com?password=1234"
|
||||
|
||||
uri = ClanURI("clan://~/Downloads")
|
||||
assert uri.get_internal() == "~/Downloads"
|
||||
|
||||
uri = ClanURI("clan:///home/user/Downloads")
|
||||
assert uri.get_internal() == "/home/user/Downloads"
|
||||
|
||||
uri = ClanURI("clan://file:///home/user/Downloads")
|
||||
assert uri.get_internal() == "/home/user/Downloads"
|
||||
|
||||
|
||||
def test_local_uri() -> None:
|
||||
# Create a ClanURI object from a local URI
|
||||
uri = ClanURI("clan://file:///home/user/Downloads")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from fixtures_flakes import FlakeForTest
|
||||
from pytest import CaptureFixture
|
||||
@@ -46,3 +47,23 @@ def test_flakes_list(
|
||||
cli.run(["flakes", "add", str(test_flake.path)])
|
||||
cli.run(cmd)
|
||||
assert str(test_flake.path) in capsys.readouterr().out
|
||||
|
||||
|
||||
@pytest.mark.impure
|
||||
def test_flakes_inspect(
|
||||
test_flake_with_core: FlakeForTest, capsys: pytest.CaptureFixture
|
||||
) -> None:
|
||||
cli = Cli()
|
||||
cli.run(
|
||||
[
|
||||
"--flake",
|
||||
str(test_flake_with_core.path),
|
||||
"flakes",
|
||||
"inspect",
|
||||
"--machine",
|
||||
"vm1",
|
||||
]
|
||||
)
|
||||
out = capsys.readouterr() # empty the buffer
|
||||
|
||||
assert "Icon" in out.out
|
||||
|
||||
@@ -3,26 +3,6 @@ import deal
|
||||
from clan_cli import nix
|
||||
|
||||
|
||||
@deal.cases(nix.nix_command)
|
||||
def test_nix_command(case: deal.TestCase) -> None:
|
||||
case()
|
||||
|
||||
|
||||
@deal.cases(nix.nix_build)
|
||||
def test_nix_build(case: deal.TestCase) -> None:
|
||||
case()
|
||||
|
||||
|
||||
@deal.cases(nix.nix_config)
|
||||
def test_nix_config(case: deal.TestCase) -> None:
|
||||
case()
|
||||
|
||||
|
||||
@deal.cases(nix.nix_eval)
|
||||
def test_nix_eval(case: deal.TestCase) -> None:
|
||||
case()
|
||||
|
||||
|
||||
@deal.cases(nix.nix_shell)
|
||||
def test_nix_shell(case: deal.TestCase) -> None:
|
||||
case()
|
||||
|
||||
Reference in New Issue
Block a user