Merge pull request 'tests: add fixtures to test_vms_cli' (#411) from lassulus-HEAD into main

This commit is contained in:
clan-bot
2023-10-05 13:58:28 +00:00

View File

@@ -1,9 +1,13 @@
import os import os
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING
import pytest import pytest
from cli import Cli from cli import Cli
if TYPE_CHECKING:
from age_keys import KeyPair
no_kvm = not os.path.exists("/dev/kvm") no_kvm = not os.path.exists("/dev/kvm")
@@ -17,6 +21,13 @@ def test_inspect(test_flake_with_core: Path, capsys: pytest.CaptureFixture) -> N
@pytest.mark.skipif(no_kvm, reason="Requires KVM") @pytest.mark.skipif(no_kvm, reason="Requires KVM")
@pytest.mark.impure @pytest.mark.impure
def test_create(test_flake_with_core: Path) -> None: def test_create(
monkeypatch: pytest.MonkeyPatch,
test_flake_with_core: Path,
age_keys: list["KeyPair"],
) -> None:
monkeypatch.chdir(test_flake_with_core)
monkeypatch.setenv("SOPS_AGE_KEY", age_keys[0].privkey)
cli = Cli() cli = Cli()
cli.run(["secrets", "users", "add", "user1", age_keys[0].pubkey])
cli.run(["vms", "create", "vm1"]) cli.run(["vms", "create", "vm1"])