(t *testing.T)
| 91 | } |
| 92 | |
| 93 | func TestListWorkflowsWithMCPServers(t *testing.T) { |
| 94 | // Create a temporary directory for test workflows |
| 95 | tmpDir := testutil.TempDir(t, "test-*") |
| 96 | workflowsDir := filepath.Join(tmpDir, constants.GetWorkflowDir()) |
| 97 | err := os.MkdirAll(workflowsDir, 0755) |
| 98 | if err != nil { |
| 99 | t.Fatalf("Failed to create test directory: %v", err) |
| 100 | } |
| 101 | |
| 102 | // Create workflow with MCP servers |
| 103 | mcpWorkflowContent := `--- |
| 104 | safe-outputs: |
| 105 | create-issue: |
| 106 | tools: |
| 107 | github: |
| 108 | mcp: |
| 109 | type: stdio |
| 110 | --- |
| 111 | # MCP Workflow` |
| 112 | |
| 113 | // Create workflow without MCP servers |
| 114 | noMcpWorkflowContent := `--- |
| 115 | on: |
| 116 | push: |
| 117 | --- |
| 118 | # No MCP Workflow` |
| 119 | |
| 120 | // Write test files |
| 121 | err = os.WriteFile(filepath.Join(workflowsDir, "with-mcp.md"), []byte(mcpWorkflowContent), 0644) |
| 122 | if err != nil { |
| 123 | t.Fatalf("Failed to create MCP workflow file: %v", err) |
| 124 | } |
| 125 | |
| 126 | err = os.WriteFile(filepath.Join(workflowsDir, "without-mcp.md"), []byte(noMcpWorkflowContent), 0644) |
| 127 | if err != nil { |
| 128 | t.Fatalf("Failed to create non-MCP workflow file: %v", err) |
| 129 | } |
| 130 | |
| 131 | // Change to the temporary directory |
| 132 | originalDir, _ := os.Getwd() |
| 133 | defer os.Chdir(originalDir) |
| 134 | os.Chdir(tmpDir) |
| 135 | |
| 136 | t.Run("list_workflows_with_mcp", func(t *testing.T) { |
| 137 | err := listWorkflowsWithMCPServers(".github/workflows", false) |
| 138 | if err != nil { |
| 139 | t.Errorf("listWorkflowsWithMCPServers failed: %v", err) |
| 140 | } |
| 141 | }) |
| 142 | |
| 143 | t.Run("list_workflows_with_mcp_verbose", func(t *testing.T) { |
| 144 | err := listWorkflowsWithMCPServers(".github/workflows", true) |
| 145 | if err != nil { |
| 146 | t.Errorf("listWorkflowsWithMCPServers verbose failed: %v", err) |
| 147 | } |
| 148 | }) |
| 149 | |
| 150 | t.Run("nonexistent_directory", func(t *testing.T) { |
nothing calls this directly
no test coverage detected