Files
awoooi/apps/api/tests/test_aider_event_processor.py
Your Name a6788c2baa
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 1m55s
fix(tests): 移 DB 測試到 integration 層修復 CI asyncpg 密碼錯誤
test_aider_event_processor.py 的三個真實 DB 測試在 CI 單元測試層
(tests/)因連線 awoooi_dev DB 失敗(密碼不符)而中斷。

正確架構:
  tests/                  — 單元測試,CI 直接跑,無 DB
  tests/integration/      — 整合測試,CI --ignore,K8s E2E 覆蓋

修復:
- tests/test_aider_event_processor.py 只保留無 DB 的 malformed payload 測試
- 三個 DB 測試移至 tests/integration/test_aider_event_processor_integration.py
  改用 conftest db_session fixture,不自建 engine(避免密碼硬碼)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 01:41:34 +08:00

24 lines
959 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# test_aider_event_processor | 2026-04-22 @ Asia/Taipei
# 需真實 DB 的三個測試已移至 tests/integration/test_aider_event_processor_integration.py
# 此檔案只保留無 DB 依賴的純單元測試,符合 CI 架構tests/ 層不連 DB
"""Unit tests for AiderEventProcessor — 無 DB 依賴。"""
import pytest
from unittest.mock import AsyncMock, MagicMock
@pytest.mark.asyncio
async def test_process_one_malformed_payload_acks_and_skips(monkeypatch):
"""malformed JSON 應 ACK 避免卡 pending且不觸碰 DB。"""
from src.workers.aider_event_processor import AiderEventProcessor
fake_r = MagicMock()
fake_r.xack = AsyncMock()
monkeypatch.setattr("src.workers.aider_event_processor.get_worker_redis",
lambda: fake_r)
proc = AiderEventProcessor()
data = {b"payload": b"this is not json"}
await proc._process_one("stream", "1-0", data)
fake_r.xack.assert_called_once()