(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func 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: `--- |
| 31 | on: push |
| 32 | tools: |
| 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: `--- |
| 44 | on: push |
| 45 | safe-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: `--- |
| 56 | on: push |
| 57 | tools: |
| 58 | edit: |
| 59 | --- |
| 60 | # Test workflow |
| 61 | `, |
| 62 | hasMCP: false, |
| 63 | mcpCount: 0, |
| 64 | }, |
| 65 | { |
| 66 | name: "workflow-with-multiple-mcp.md", |
| 67 | content: `--- |
| 68 | on: push |
| 69 | tools: |
| 70 | github: |
nothing calls this directly
no test coverage detected