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

Function TestParserMCPErrorMessageQuality

pkg/workflow/mcp_error_messages_test.go:147–333  ·  view source on GitHub ↗

TestParserMCPErrorMessageQuality verifies error messages in pkg/parser/mcp.go

(t *testing.T)

Source from the content-addressed store, hash-verified

145
146// TestParserMCPErrorMessageQuality verifies error messages in pkg/parser/mcp.go
147func TestParserMCPErrorMessageQuality(t *testing.T) {
148 tests := []struct {
149 name string
150 toolName string
151 mcpSection any
152 toolConfig map[string]any
153 expectError bool
154 errorContains []string
155 errorShould string
156 }{
157 {
158 name: "invalid mcp configuration format - wrong type",
159 toolName: "my-tool",
160 mcpSection: 12345, // should be map or string
161 toolConfig: map[string]any{},
162 expectError: true,
163 errorContains: []string{
164 "mcp configuration must be a map or JSON string",
165 "got int",
166 "Example:",
167 "mcp-servers:",
168 "my-tool:",
169 "command:",
170 },
171 errorShould: "show received type and provide example",
172 },
173 {
174 name: "type field must be string",
175 toolName: "my-tool",
176 mcpSection: map[string]any{
177 "type": 123, // should be string
178 "command": "npx",
179 },
180 toolConfig: map[string]any{},
181 expectError: true,
182 errorContains: []string{
183 "type field must be a string",
184 "got int",
185 "Valid types are: stdio, http",
186 "Example:",
187 "type: stdio",
188 },
189 errorShould: "show received type, list valid types, and provide example",
190 },
191 {
192 name: "stdio missing command or container",
193 toolName: "incomplete",
194 mcpSection: map[string]any{
195 "type": "stdio",
196 "args": []string{"--port", "3000"},
197 },
198 toolConfig: map[string]any{},
199 expectError: true,
200 errorContains: []string{
201 "stdio MCP tool",
202 "must specify either 'command' or 'container'",
203 "Cannot specify both",
204 "Example with command:",

Callers

nothing calls this directly

Calls 4

ParseMCPConfigFunction · 0.92
RunMethod · 0.45
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected