2023-08-24 16:06:56 +00:00
|
|
|
import pytest
|
|
|
|
from cli import Cli
|
2023-10-24 14:44:54 +00:00
|
|
|
from fixtures_flakes import FlakeForTest
|
2023-08-24 16:06:56 +00:00
|
|
|
|
2023-10-24 14:50:03 +00:00
|
|
|
|
2023-12-14 17:25:42 +00:00
|
|
|
@pytest.mark.impure
|
2023-10-24 14:50:03 +00:00
|
|
|
def test_machine_subcommands(
|
2023-12-14 17:25:42 +00:00
|
|
|
test_flake_with_core: FlakeForTest, capsys: pytest.CaptureFixture
|
2023-10-24 14:50:03 +00:00
|
|
|
) -> None:
|
2023-08-24 16:06:56 +00:00
|
|
|
cli = Cli()
|
2023-12-14 17:25:42 +00:00
|
|
|
cli.run(
|
2024-05-29 08:10:10 +00:00
|
|
|
["machines", "create", "--flake", str(test_flake_with_core.path), "machine1"]
|
2023-12-14 17:25:42 +00:00
|
|
|
)
|
2023-08-24 16:06:56 +00:00
|
|
|
|
|
|
|
capsys.readouterr()
|
2024-05-29 08:10:10 +00:00
|
|
|
cli.run(["machines", "list", "--flake", str(test_flake_with_core.path)])
|
2024-01-10 16:31:11 +00:00
|
|
|
|
2023-08-24 16:06:56 +00:00
|
|
|
out = capsys.readouterr()
|
2024-05-26 11:22:59 +00:00
|
|
|
|
|
|
|
assert "machine1" in out.out
|
2024-05-26 12:17:17 +00:00
|
|
|
assert "vm1" in out.out
|
|
|
|
assert "vm2" in out.out
|
2023-08-24 16:06:56 +00:00
|
|
|
|
2024-05-31 09:50:12 +00:00
|
|
|
capsys.readouterr()
|
|
|
|
cli.run(["machines", "show", "--flake", str(test_flake_with_core.path), "machine1"])
|
|
|
|
out = capsys.readouterr()
|
|
|
|
assert "machine1" in out.out
|
|
|
|
assert "Description" in out.out
|
|
|
|
print(out)
|
|
|
|
|
2023-12-14 17:25:42 +00:00
|
|
|
cli.run(
|
2024-05-29 08:10:10 +00:00
|
|
|
["machines", "delete", "--flake", str(test_flake_with_core.path), "machine1"]
|
2023-12-14 17:25:42 +00:00
|
|
|
)
|
2023-08-24 16:06:56 +00:00
|
|
|
|
|
|
|
capsys.readouterr()
|
2024-05-29 08:10:10 +00:00
|
|
|
cli.run(["machines", "list", "--flake", str(test_flake_with_core.path)])
|
2023-08-24 16:06:56 +00:00
|
|
|
out = capsys.readouterr()
|
2024-05-26 11:22:59 +00:00
|
|
|
|
|
|
|
assert "machine1" not in out.out
|
2024-05-26 12:17:17 +00:00
|
|
|
assert "vm1" in out.out
|
|
|
|
assert "vm2" in out.out
|