26 lines
736 B
Python
26 lines
736 B
Python
import subprocess
|
|
|
|
from typer.testing import CliRunner
|
|
|
|
from l4d2host.cli import app
|
|
|
|
|
|
def test_help_lists_v1_commands() -> None:
|
|
result = CliRunner().invoke(app, ["--help"])
|
|
assert result.exit_code == 0
|
|
for command in ["install", "initialize", "start", "stop", "delete"]:
|
|
assert command in result.output
|
|
|
|
|
|
def test_cli_propagates_subprocess_return_code(monkeypatch) -> None:
|
|
def fail(*args, **kwargs):
|
|
del args
|
|
del kwargs
|
|
raise subprocess.CalledProcessError(returncode=9, cmd=["x"], stderr="boom")
|
|
|
|
monkeypatch.setattr("l4d2host.cli.start_instance", fail)
|
|
|
|
result = CliRunner().invoke(app, ["start", "alpha"])
|
|
|
|
assert result.exit_code == 9
|
|
assert "boom" in result.stderr
|