MCPcopy Create free account
hub / github.com/astercloud/aster / AssertToolError

Function AssertToolError

pkg/tools/builtin/testutils.go:319–331  ·  view source on GitHub ↗

AssertToolError 断言工具执行失败

(t *testing.T, result map[string]any)

Source from the content-addressed store, hash-verified

317
318// AssertToolError 断言工具执行失败
319func AssertToolError(t *testing.T, result map[string]any) string {
320 if ok, exists := result["ok"]; exists && ok.(bool) {
321 t.Errorf("Expected tool to fail, but it succeeded")
322 }
323
324 if errMsg, exists := result["error"]; exists {
325 if errStr, ok := errMsg.(string); ok {
326 return errStr
327 }
328 }
329 t.Errorf("Expected error message in result, got: %+v", result)
330 return ""
331}
332
333// AssertContains 断言字符串包含子字符串
334func AssertContains(t *testing.T, str, substr string) {

Calls

no outgoing calls