MCPcopy
hub / github.com/github/github-mcp-server / TestWithTools

Function TestWithTools

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

Source from the content-addressed store, hash-verified

381}
382
383func TestWithTools(t *testing.T) {
384 tools := []ServerTool{
385 mockTool("tool1", "toolset1", true),
386 mockTool("tool2", "toolset1", true),
387 mockTool("tool3", "toolset2", true),
388 }
389
390 // WithTools adds additional tools that bypass toolset filtering
391 // When combined with WithToolsets([]), only the additional tools should be available
392 filteredReg := mustBuild(t, NewBuilder().SetTools(tools).WithToolsets([]string{}).WithTools([]string{"tool1", "tool3"}))
393 filteredTools := filteredReg.AvailableTools(context.Background())
394
395 if len(filteredTools) != 2 {
396 t.Fatalf("Expected 2 filtered tools, got %d", len(filteredTools))
397 }
398
399 toolNames := make(map[string]bool)
400 for _, tool := range filteredTools {
401 toolNames[tool.Tool.Name] = true
402 }
403 if !toolNames["tool1"] || !toolNames["tool3"] {
404 t.Errorf("Expected tool1 and tool3, got %v", toolNames)
405 }
406}
407
408func TestChainedFilters(t *testing.T) {
409 tools := []ServerTool{

Callers

nothing calls this directly

Calls 7

mustBuildFunction · 0.85
NewBuilderFunction · 0.85
WithToolsMethod · 0.80
WithToolsetsMethod · 0.80
SetToolsMethod · 0.80
AvailableToolsMethod · 0.80
mockToolFunction · 0.70

Tested by

no test coverage detected