2023-11-09 08:30:25 +00:00
|
|
|
import pytest
|
2023-10-16 13:03:53 +00:00
|
|
|
from fixtures_flakes import FlakeForTest
|
2023-08-26 06:46:53 +00:00
|
|
|
|
2024-06-10 05:19:38 +00:00
|
|
|
from clan_cli.config.machine import (
|
|
|
|
config_for_machine,
|
|
|
|
set_config_for_machine,
|
|
|
|
verify_machine_config,
|
|
|
|
)
|
2023-11-09 08:30:25 +00:00
|
|
|
from clan_cli.config.schema import machine_schema
|
2024-06-09 09:38:19 +00:00
|
|
|
from clan_cli.machines.create import MachineCreateRequest, create_machine
|
|
|
|
from clan_cli.machines.list import list_machines
|
2023-08-26 06:46:53 +00:00
|
|
|
|
|
|
|
|
2023-11-09 08:30:25 +00:00
|
|
|
@pytest.mark.with_core
|
|
|
|
def test_schema_for_machine(test_flake_with_core: FlakeForTest) -> None:
|
2023-11-15 13:28:40 +00:00
|
|
|
schema = machine_schema(test_flake_with_core.path, config={})
|
2023-08-26 06:46:53 +00:00
|
|
|
assert "properties" in schema
|
2024-06-09 09:38:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.with_core
|
|
|
|
def test_create_machine_on_minimal_clan(test_flake_minimal: FlakeForTest) -> None:
|
|
|
|
assert list_machines(test_flake_minimal.path) == []
|
|
|
|
create_machine(
|
|
|
|
test_flake_minimal.path,
|
|
|
|
MachineCreateRequest(
|
|
|
|
name="foo", config=dict(nixpkgs=dict(hostSystem="x86_64-linux"))
|
|
|
|
),
|
|
|
|
)
|
|
|
|
assert list_machines(test_flake_minimal.path) == ["foo"]
|
2024-06-10 05:19:38 +00:00
|
|
|
set_config_for_machine(
|
|
|
|
test_flake_minimal.path, "foo", dict(services=dict(openssh=dict(enable=True)))
|
|
|
|
)
|
|
|
|
config = config_for_machine(test_flake_minimal.path, "foo")
|
|
|
|
assert config["services"]["openssh"]["enable"]
|
|
|
|
assert verify_machine_config(test_flake_minimal.path, "foo") is None
|