33 lines
1 KiB
Python
33 lines
1 KiB
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from l4d2host.instances import delete_instance, start_instance
|
|
|
|
|
|
def test_start_order(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
calls: list[list[str]] = []
|
|
|
|
def fake_run_command(cmd, **kwargs):
|
|
del kwargs
|
|
calls.append(list(cmd))
|
|
|
|
instance_dir = tmp_path / "instances" / "alpha"
|
|
runtime_dir = tmp_path / "runtime" / "alpha"
|
|
(runtime_dir / "merged" / "left4dead2" / "cfg").mkdir(parents=True, exist_ok=True)
|
|
instance_dir.mkdir(parents=True, exist_ok=True)
|
|
(instance_dir / "instance.env").write_text(
|
|
"L4D2_PORT=27015\nL4D2_ARGS=-tickrate 100\nL4D2_LOWERDIRS=/x:/y\n"
|
|
)
|
|
(instance_dir / "server.cfg").write_text("sv_consistency 1")
|
|
|
|
monkeypatch.setattr("l4d2host.instances.run_command", fake_run_command)
|
|
|
|
start_instance("alpha", root=tmp_path)
|
|
|
|
assert calls[0][0] == "fuse-overlayfs"
|
|
assert calls[1][:3] == ["systemctl", "--user", "start"]
|
|
|
|
|
|
def test_delete_missing_is_noop(tmp_path: Path) -> None:
|
|
delete_instance("missing", root=tmp_path)
|