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

Function TestToolsetInstructionsFunc

pkg/inventory/instructions_test.go:142–207  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

140}
141
142func TestToolsetInstructionsFunc(t *testing.T) {
143 tests := []struct {
144 name string
145 toolsets []ToolsetMetadata
146 expectedToContain string
147 notExpectedToContain string
148 }{
149 {
150 name: "toolset with context-aware instructions includes extra text when dependency present",
151 toolsets: []ToolsetMetadata{
152 {ID: "repos", Description: "Repos"},
153 {
154 ID: "pull_requests",
155 Description: "PRs",
156 InstructionsFunc: func(inv *Inventory) string {
157 instructions := "PR base instructions"
158 if inv.HasToolset("repos") {
159 instructions += " PR template instructions"
160 }
161 return instructions
162 },
163 },
164 },
165 expectedToContain: "PR template instructions",
166 },
167 {
168 name: "toolset with context-aware instructions excludes extra text when dependency missing",
169 toolsets: []ToolsetMetadata{
170 {
171 ID: "pull_requests",
172 Description: "PRs",
173 InstructionsFunc: func(inv *Inventory) string {
174 instructions := "PR base instructions"
175 if inv.HasToolset("repos") {
176 instructions += " PR template instructions"
177 }
178 return instructions
179 },
180 },
181 },
182 notExpectedToContain: "PR template instructions",
183 },
184 {
185 name: "toolset without InstructionsFunc returns no toolset-specific instructions",
186 toolsets: []ToolsetMetadata{
187 {ID: "test", Description: "Test without instructions"},
188 },
189 notExpectedToContain: "## Test",
190 },
191 }
192
193 for _, tt := range tests {
194 t.Run(tt.name, func(t *testing.T) {
195 inv := createTestInventory(tt.toolsets)
196 result := generateInstructions(inv)
197
198 if tt.expectedToContain != "" && !strings.Contains(result, tt.expectedToContain) {
199 t.Errorf("Expected result to contain '%s', but it did not. Result: %s", tt.expectedToContain, result)

Callers

nothing calls this directly

Calls 3

createTestInventoryFunction · 0.85
generateInstructionsFunction · 0.85
HasToolsetMethod · 0.80

Tested by

no test coverage detected