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

Function TestFindWorkflowsWithMCPServer

pkg/cli/mcp_list_tools_test.go:150–233  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

148}
149
150func TestFindWorkflowsWithMCPServer(t *testing.T) {
151 // Create a temporary directory for test workflows
152 tmpDir := testutil.TempDir(t, "test-*")
153 workflowsDir := filepath.Join(tmpDir, constants.GetWorkflowDir())
154 err := os.MkdirAll(workflowsDir, 0755)
155 if err != nil {
156 t.Fatalf("Failed to create test directory: %v", err)
157 }
158
159 // Create multiple workflows, some with the target MCP server
160 workflow1Content := `---
161tools:
162 github:
163 allowed: ["create_issue"]
164---
165# Workflow 1`
166
167 workflow2Content := `---
168safe-outputs:
169 create-issue:
170tools:
171 playwright:
172---
173# Workflow 2`
174
175 workflow3Content := `---
176tools:
177 github:
178 allowed: ["add_comment"]
179---
180# Workflow 3`
181
182 // Write workflow files
183 workflows := map[string]string{
184 "workflow1.md": workflow1Content,
185 "workflow2.md": workflow2Content,
186 "workflow3.md": workflow3Content,
187 }
188
189 for filename, content := range workflows {
190 path := filepath.Join(workflowsDir, filename)
191 err = os.WriteFile(path, []byte(content), 0644)
192 if err != nil {
193 t.Fatalf("Failed to create %s: %v", filename, err)
194 }
195 }
196
197 // Change to the temporary directory
198 originalDir, _ := os.Getwd()
199 defer os.Chdir(originalDir)
200 os.Chdir(tmpDir)
201
202 t.Run("find_github_server", func(t *testing.T) {
203 // Should find workflow1 and workflow3 (both have github MCP server)
204 err := findWorkflowsWithMCPServer(workflowsDir, "github", false)
205 if err != nil {
206 t.Errorf("findWorkflowsWithMCPServer failed: %v", err)
207 }

Callers

nothing calls this directly

Calls 6

TempDirFunction · 0.92
GetWorkflowDirFunction · 0.92
RunMethod · 0.45
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected