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

Function TestScanWorkflowsForMCP

pkg/cli/mcp_workflow_scanner_test.go:13–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestScanWorkflowsForMCP(t *testing.T) {
14 // Create a temporary directory for test workflows
15 tmpDir := testutil.TempDir(t, "test-*")
16 workflowsDir := filepath.Join(tmpDir, ".github", "workflows")
17 if err := os.MkdirAll(workflowsDir, 0755); err != nil {
18 t.Fatalf("Failed to create workflows directory: %v", err)
19 }
20
21 // Create test workflow files
22 testCases := []struct {
23 name string
24 content string
25 hasMCP bool
26 mcpCount int
27 }{
28 {
29 name: "workflow-with-github-mcp.md",
30 content: `---
31on: push
32tools:
33 github:
34 allowed: [create_issue]
35---
36# Test workflow
37`,
38 hasMCP: true,
39 mcpCount: 1,
40 },
41 {
42 name: "workflow-with-safe-outputs.md",
43 content: `---
44on: push
45safe-outputs:
46 create-issue:
47---
48# Test workflow
49`,
50 hasMCP: true,
51 mcpCount: 1,
52 },
53 {
54 name: "workflow-without-mcp.md",
55 content: `---
56on: push
57tools:
58 edit:
59---
60# Test workflow
61`,
62 hasMCP: false,
63 mcpCount: 0,
64 },
65 {
66 name: "workflow-with-multiple-mcp.md",
67 content: `---
68on: push
69tools:
70 github:

Callers

nothing calls this directly

Calls 5

TempDirFunction · 0.92
ScanWorkflowsForMCPFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected