chore: initialize project repository
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import pytest
|
||||
|
||||
from app.infrastructure.memory_cache import MemoryCacheAdapter
|
||||
|
||||
|
||||
class FailingCache:
|
||||
async def get(self, key: str) -> str:
|
||||
raise ConnectionError("redis unavailable")
|
||||
|
||||
async def set(self, key: str, value: str, ex: int | None = None) -> None:
|
||||
raise ConnectionError("redis unavailable")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cache_read_degrades_without_raising() -> None:
|
||||
result = await MemoryCacheAdapter(FailingCache()).get("memory:1")
|
||||
assert result.value is None
|
||||
assert result.degraded is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cache_write_failure_does_not_block_primary_store() -> None:
|
||||
assert not await MemoryCacheAdapter(FailingCache()).set("memory:1", "value")
|
||||
Reference in New Issue
Block a user