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

Function TestWithReadOnly

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

Source from the content-addressed store, hash-verified

122}
123
124func TestWithReadOnly(t *testing.T) {
125 tools := []ServerTool{
126 mockTool("read_tool", "toolset1", true),
127 mockTool("write_tool", "toolset1", false),
128 }
129
130 // Build without read-only - should have both tools
131 reg := mustBuild(t, NewBuilder().SetTools(tools).WithToolsets([]string{"all"}))
132 allTools := reg.AvailableTools(context.Background())
133 if len(allTools) != 2 {
134 t.Fatalf("Expected 2 tools without read-only, got %d", len(allTools))
135 }
136
137 // Build with read-only - should filter out write tools
138 readOnlyReg := mustBuild(t, NewBuilder().SetTools(tools).WithToolsets([]string{"all"}).WithReadOnly(true))
139 readOnlyTools := readOnlyReg.AvailableTools(context.Background())
140 if len(readOnlyTools) != 1 {
141 t.Fatalf("Expected 1 tool in read-only, got %d", len(readOnlyTools))
142 }
143 if readOnlyTools[0].Tool.Name != "read_tool" {
144 t.Errorf("Expected read_tool, got %s", readOnlyTools[0].Tool.Name)
145 }
146}
147
148func TestWithToolsets(t *testing.T) {
149 tools := []ServerTool{

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected