feat: 31 new tests, metrics LLM counters, Dockerfile caching, Makefile targets, compose limits, code fixes
This commit is contained in:
34
tests/test_config.py
Normal file
34
tests/test_config.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""Tests for config module — _env_int error path."""
|
||||
|
||||
import os
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
def test_env_int_invalid_value_warns_and_returns_default():
|
||||
from guarddog_nexus.config import _env_int
|
||||
|
||||
os.environ["TEST_PORT"] = "notanumber"
|
||||
|
||||
with patch("logging.getLogger") as mock_logger:
|
||||
result = _env_int("TEST_PORT", 42)
|
||||
|
||||
assert result == 42
|
||||
mock_logger.return_value.warning.assert_called_once()
|
||||
|
||||
del os.environ["TEST_PORT"]
|
||||
|
||||
|
||||
def test_env_int_missing_returns_default():
|
||||
from guarddog_nexus.config import _env_int
|
||||
|
||||
os.environ.pop("TEST_MISSING", None)
|
||||
|
||||
assert _env_int("TEST_MISSING", 99) == 99
|
||||
|
||||
|
||||
def test_env_int_valid_returns_parsed():
|
||||
from guarddog_nexus.config import _env_int
|
||||
|
||||
os.environ["TEST_VALID"] = "8080"
|
||||
assert _env_int("TEST_VALID", 42) == 8080
|
||||
del os.environ["TEST_VALID"]
|
||||
Reference in New Issue
Block a user