Skip to content

Test: handler glue integration (errorResult conversion + tdlib wiring) #14

@kiki830621

Description

@kiki830621

Problem

ServerHandlerLogicTests 直接呼叫 parseGetChatHistoryArgs(),但 handler glue code(Server.swift:351-364)負責:

  1. HandlerArgError/DateParseErrorerrorResult(e.description) 轉換
  2. CallTool.Result.isError = true 旗標
  3. GetChatHistoryArgs 的 6 個欄位 wire 到 tdlib.getChatHistory(...)

From verification of #7 by Codex (MEDIUM):
「這批新增測試沒有真正測到 handler 行為,只測到抽出的 parser。現在的測試沒有驗證 CallTool.Result.isError、錯誤訊息內容、也沒有驗證 handler 層的參數轉接,因此若之後是 handler glue 壞掉而不是 parser 壞掉,這組測試仍會全綠。」

Type

enhancement

Expected

加 handler-level integration test 類 fixture:

  • Mock 或 stub TDLibClient.getChatHistory spy call 參數
  • 驗證 errorResultisError: true + message 格式
  • 驗證 GetChatHistoryArgs 6 個欄位正確傳到 tdlib 呼叫
  • 可考慮用 protocol-based mock 或 Swift 的 @MainActor test helper

Code Reference

  • Sources/CheTelegramAllMCPCore/Server.swift:348-366 (handler glue)
  • Tests/CheTelegramAllMCPTests/ServerHandlerLogicTests.swift (只測 parser)

Related: #7

Implementation history


Current Status

Phase: closed-partial
Last updated: 2026-04-27 by idd-close

Key Decisions

Scope Changes

Blocking

(none — accepting PARTIALLY closure with explicit follow-up #27)

Test counts

  • Batch total: 163 → 180 (+17)
  • HandlerGlueTests: 6 + 2 (verify-DA F2) = 8 tests

Commits

Subsumed

Follow-up (verify-DA)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions