fix: reject REDIS_CACHE_TTL<=0 (kill implicit never-expire)

This commit is contained in:
2026-07-16 05:25:36 -04:00
parent 564c92a043
commit 7cc6aa5b23
5 changed files with 46 additions and 6 deletions
+16
View File
@@ -0,0 +1,16 @@
"""工程配置校验单元测试(Redis 缓存 TTL fail-loud)。"""
from __future__ import annotations
import pytest
def test_redis_cache_ttl_zero_rejected() -> None:
"""REDIS_CACHE_TTL<=0 必须启动即报错,消灭'0=永不过期'隐式语义。"""
from adapters.redis_cache import _resolve_cache_ttl
with pytest.raises(ValueError, match="REDIS_CACHE_TTL"):
_resolve_cache_ttl(0)
with pytest.raises(ValueError, match="REDIS_CACHE_TTL"):
_resolve_cache_ttl(-1)
assert _resolve_cache_ttl(86400) == 86400