Problem
From verification of #9/#10/#14 by devils-advocate (HIGH) + Codex:
「HandlerGlueTests.testGetChatHistoryGlueChatIdMissing 的程式形狀:
do {
_ = try parseGetChatHistoryArgs([:])
} catch {
result = errorResultFromParse(error) // ← 測試自己呼叫
}
問題:這段程式不在 Server.swift 裡執行。它只是模仿 Server.swift 的程式形狀。
如果有人把 Server.swift 從 return errorResultFromParse(error) 改成 hardcode return errorResult("changed!"):
- HandlerGlueTests 全部 6 個測試仍然 PASS — 因為它們測
errorResultFromParse(_:) 本身
- production code 已經回傳
"changed!" 給 MCP client,但整個 test suite 不會炸」
— Source: team:devils-advocate (HIGH) + Codex independent confirmation
#14 + #18 因此標 PARTIALLY closed。需要真正打到 Server.handleToolCall entry point 的 integration test。
Type
enhancement (test infrastructure)
Expected
讓 Server.handleToolCall 從 private 升 internal(或抽出 testable wrapper),寫 1-2 個 integration test:
func testHandleToolCallGetChatHistoryWithMissingChatIdReturnsError() async {
let server = makeTestServer() // needs TDLib stub state
let result = await server.handleToolCall(name: "get_chat_history", arguments: [:])
XCTAssertTrue(result.isError ?? false)
if case let .text(text, _, _) = result.content[0] {
XCTAssertTrue(text.hasPrefix("Error: chat_id is required"))
}
}
挑戰:
Server 需要 TDLibClient 實例 — 需 stub init flow(TDLibClient.makeStubForTesting()?)
- 或:抽
private func handleToolCall 為獨立 dispatch function 接受 closure dependency
兩個方案都涉及 architectural change。第二方案更乾淨(純函式 dispatch)但動到更多 code。
Acceptance
Code Reference
Sources/CheTelegramAllMCPCore/Server.swift:280 (handleToolCall — currently private)
Sources/CheTelegramAllMCPCore/Server.swift:391-405 (get_chat_history catch arm)
Sources/CheTelegramAllMCPCore/Server.swift:509-517 (dump_chat_to_markdown catch arm)
Tests/CheTelegramAllMCPTests/HandlerGlueTests.swift (current test approach — needs supplement)
Related: #14, #18, #7
Problem
#14 + #18 因此標 PARTIALLY closed。需要真正打到
Server.handleToolCallentry point 的 integration test。Type
enhancement (test infrastructure)
Expected
讓
Server.handleToolCall從private升internal(或抽出 testable wrapper),寫 1-2 個 integration test:挑戰:
Server需要TDLibClient實例 — 需 stub init flow(TDLibClient.makeStubForTesting()?)private func handleToolCall為獨立 dispatch function 接受 closure dependency兩個方案都涉及 architectural change。第二方案更乾淨(純函式 dispatch)但動到更多 code。
Acceptance
Server.handleToolCall變 testable(升 visibility 或抽 dispatch function)handleToolCall(...)並斷言CallTool.Result.isError == true+ text payloaderrorResult("changed!")應立即造成 1+ integration test failCode Reference
Sources/CheTelegramAllMCPCore/Server.swift:280(handleToolCall — currentlyprivate)Sources/CheTelegramAllMCPCore/Server.swift:391-405(get_chat_history catch arm)Sources/CheTelegramAllMCPCore/Server.swift:509-517(dump_chat_to_markdown catch arm)Tests/CheTelegramAllMCPTests/HandlerGlueTests.swift(current test approach — needs supplement)Related: #14, #18, #7