"""Config validation."""
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parent.parent))

from app.config import ServerConfig  # noqa: E402


def test_model_validator_clamps_unknown():
    assert ServerConfig(model="gpt").model == "auto"
    assert ServerConfig(model="large-v3-turbo").model == "large-v3-turbo"


def test_device_validator():
    assert ServerConfig(device="gpu").device == "auto"
    assert ServerConfig(device="cuda").device == "cuda"


def test_port_validator():
    assert ServerConfig(port=70000).port == 8590
    assert ServerConfig(port=9000).port == 9000


def test_env_override(monkeypatch):
    monkeypatch.setenv("VOXCAST_SERVER_PORT", "9999")
    assert ServerConfig().port == 9999
