MCPcopy Create free account
hub / github.com/github/gh-aw / TestMCPErrorMessageStructure

Function TestMCPErrorMessageStructure

pkg/workflow/mcp_error_messages_test.go:336–414  ·  view source on GitHub ↗

TestMCPErrorMessageStructure verifies that all error messages have consistent structure

(t *testing.T)

Source from the content-addressed store, hash-verified

334
335// TestMCPErrorMessageStructure verifies that all error messages have consistent structure
336func TestMCPErrorMessageStructure(t *testing.T) {
337 testCases := []struct {
338 description string
339 toolConfig map[string]any
340 toolName string
341 }{
342 {
343 description: "unknown property",
344 toolConfig: map[string]any{
345 "command": "npx",
346 "invalid": "value",
347 },
348 toolName: "test-tool",
349 },
350 {
351 description: "missing required fields",
352 toolConfig: map[string]any{
353 "args": []string{"test"},
354 },
355 toolName: "test-tool",
356 },
357 {
358 description: "http without url",
359 toolConfig: map[string]any{
360 "type": "http",
361 },
362 toolName: "test-tool",
363 },
364 {
365 description: "unsupported type",
366 toolConfig: map[string]any{
367 "type": "invalid",
368 "command": "test",
369 },
370 toolName: "test-tool",
371 },
372 }
373
374 for _, tc := range testCases {
375 t.Run(tc.description, func(t *testing.T) {
376 _, err := getMCPConfig(tc.toolConfig, tc.toolName)
377 if err == nil {
378 t.Fatal("Expected error but got none")
379 }
380
381 errMsg := err.Error()
382
383 // Count newlines to verify multi-line example
384 newlineCount := strings.Count(errMsg, "\n")
385 if !strings.Contains(errMsg, "Example:") {
386 // Some errors might not have examples in all cases
387 return
388 }
389
390 if newlineCount < 2 {
391 t.Error("Multi-line examples should have at least 2 newlines for YAML structure")
392 }
393

Callers

nothing calls this directly

Calls 4

getMCPConfigFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected