from __future__ import annotations

import pytest

from src.error_handlers import ErrorHandler
from src.errors import CacheError


@pytest.mark.asyncio
async def test_cache_error_handler_returns_degraded_success() -> None:
    handler = ErrorHandler()

    result = await handler.handle(CacheError("redis unavailable", operation="get"))

    assert result.ok is True
    assert result.error is None
    assert result.data["cache"] == "degraded"
    assert "continued without cache" in result.data["message"]
