MCPcopy Index your code
hub / github.com/github/github-mcp-server / TestUnrecognizedToolsets

Function TestUnrecognizedToolsets

pkg/inventory/registry_test.go:223–278  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

221}
222
223func TestUnrecognizedToolsets(t *testing.T) {
224 tools := []ServerTool{
225 mockTool("tool1", "toolset1", true),
226 mockTool("tool2", "toolset2", true),
227 }
228
229 tests := []struct {
230 name string
231 input []string
232 expectedUnrecognized []string
233 }{
234 {
235 name: "all valid",
236 input: []string{"toolset1", "toolset2"},
237 expectedUnrecognized: nil,
238 },
239 {
240 name: "one invalid",
241 input: []string{"toolset1", "invalid_toolset"},
242 expectedUnrecognized: []string{"invalid_toolset"},
243 },
244 {
245 name: "multiple invalid",
246 input: []string{"typo1", "toolset1", "typo2"},
247 expectedUnrecognized: []string{"typo1", "typo2"},
248 },
249 {
250 name: "invalid with whitespace trimmed",
251 input: []string{" invalid_tool "},
252 expectedUnrecognized: []string{"invalid_tool"},
253 },
254 {
255 name: "empty input",
256 input: []string{},
257 expectedUnrecognized: nil,
258 },
259 }
260
261 for _, tt := range tests {
262 t.Run(tt.name, func(t *testing.T) {
263 filtered := mustBuild(t, NewBuilder().SetTools(tools).WithToolsets(tt.input))
264 unrecognized := filtered.UnrecognizedToolsets()
265
266 if len(unrecognized) != len(tt.expectedUnrecognized) {
267 t.Fatalf("Expected %d unrecognized, got %d: %v",
268 len(tt.expectedUnrecognized), len(unrecognized), unrecognized)
269 }
270
271 for i, expected := range tt.expectedUnrecognized {
272 if unrecognized[i] != expected {
273 t.Errorf("Expected unrecognized[%d] = %q, got %q", i, expected, unrecognized[i])
274 }
275 }
276 })
277 }
278}
279
280func TestBuildErrorsOnUnrecognizedTools(t *testing.T) {

Callers

nothing calls this directly

Calls 6

mustBuildFunction · 0.85
NewBuilderFunction · 0.85
WithToolsetsMethod · 0.80
SetToolsMethod · 0.80
UnrecognizedToolsetsMethod · 0.80
mockToolFunction · 0.70

Tested by

no test coverage detected