Problem
From verification of #8/#11/#12 by devils-advocate (MEDIUM):
「七個 throws-based test 升級成 exact-string equality(#11):
XCTAssertEqual(
(error as? HandlerArgError)?.description,
"max_messages exceeds 10_000 cap; got 50000. Use since_date/until_date to narrow the range."
)
問題:
- 鎖死 cap 數值
10_000。如果未來 cap policy 改成 5_000,所有相關 test 同時 fail。validateMaxMessagesCap 的「single source of truth」精神被測試打破了。
- 鎖死 error suggestion 文字。本意是 helpful UX,但每次 wording 微調都觸發 test failure。
- 鎖死 錯誤訊息結尾的句點。
#11 issue body 原文要求是「assert error message TEXT」,並沒指定 exact equality。實作選擇 exact 是 over-shoot。」
— Source: team:devils-advocate
Type
enhancement (test refactor)
Expected
把 7 個 exact-equality assertion 改成 prefix-match:
// Before:
XCTAssertEqual(
(error as? HandlerArgError)?.description,
"max_messages exceeds 10_000 cap; got 50000. Use since_date/until_date to narrow the range."
)
// After:
XCTAssertTrue(
(error as? HandlerArgError)?.description.hasPrefix("max_messages exceeds") == true,
"expected cap-error prefix; got \(...)"
)
平衡 contract 鎖定(前綴是 caller 可能 substring-match 的 stable surface)和 implementation 彈性(cap 數值 / suggestion 文字可調)。
Acceptance
Code Reference
Tests/CheTelegramAllMCPTests/ServerHandlerLogicTests.swift 7 個 throws-based test 的 trailing closures (search "XCTAssertEqual.*description")
Related: #8, #11
Problem
Type
enhancement (test refactor)
Expected
把 7 個 exact-equality assertion 改成 prefix-match:
平衡 contract 鎖定(前綴是 caller 可能 substring-match 的 stable surface)和 implementation 彈性(cap 數值 / suggestion 文字可調)。
Acceptance
XCTAssertEqual改成hasPrefix/containsCode Reference
Tests/CheTelegramAllMCPTests/ServerHandlerLogicTests.swift7 個 throws-based test 的 trailing closures (search "XCTAssertEqual.*description")Related: #8, #11