test: close coverage gaps + opt-in integration smoke

Unit-Tests (kein Docker nötig), 130 Tests gesamt:
- config: ${ENV}- und ~-Expansion in hf_home
- prompt_io: _pin_dns (DNS-Rebinding wird abgewiesen, andere Hosts unberührt,
  Resolver wird wiederhergestellt)
- actions: do_check (running/healthy, missing), do_start non-dry-run
  (Happy-Path + Readiness-Fehler mit --logs), _container_lock Force-Bypass
- cli: --max-tokens <= 0 abgelehnt, --expose/--no-expose

scripts/smoke.sh: opt-in End-to-End-Test gegen echten Docker + llama.cpp-Server
(--api-key-Round-Trip inkl. 401/200, start/check/chat/stream/stop, eigener
Container/Port, Cleanup-Trap).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-07-06 17:08:10 +02:00
commit f83f36fdfb
6 changed files with 268 additions and 4 deletions

View file

@ -181,6 +181,22 @@ def test_lock_file_derived_from_container_name(tmp_path):
assert str(server_cfg.lock_file) == "/tmp/llamacppctl.test_default.lock"
def test_hf_home_expands_env_var(tmp_path, monkeypatch):
monkeypatch.setenv("LLAMACPPCTL_TEST_HOME", "/data/models")
cfg = CONFIG_BASIC.replace("hf_home = /srv/models", "hf_home = ${LLAMACPPCTL_TEST_HOME}/sub")
cfg_path = _write_config(tmp_path, cfg)
server_cfg, _ = resolve_effective_config(_parse(["--start", "--config", str(cfg_path)]))
assert str(server_cfg.hf_home) == "/data/models/sub"
def test_hf_home_expands_tilde(tmp_path, monkeypatch):
monkeypatch.setenv("HOME", "/home/tester")
cfg = CONFIG_BASIC.replace("hf_home = /srv/models", "hf_home = ~/models")
cfg_path = _write_config(tmp_path, cfg)
server_cfg, _ = resolve_effective_config(_parse(["--start", "--config", str(cfg_path)]))
assert str(server_cfg.hf_home) == "/home/tester/models"
def test_builtin_defaults_has_container_name():
defaults = builtin_defaults()
assert defaults["container_name"] == "va_llm"