(t *testing.T)
| 148 | } |
| 149 | |
| 150 | func 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 := `--- |
| 161 | tools: |
| 162 | github: |
| 163 | allowed: ["create_issue"] |
| 164 | --- |
| 165 | # Workflow 1` |
| 166 | |
| 167 | workflow2Content := `--- |
| 168 | safe-outputs: |
| 169 | create-issue: |
| 170 | tools: |
| 171 | playwright: |
| 172 | --- |
| 173 | # Workflow 2` |
| 174 | |
| 175 | workflow3Content := `--- |
| 176 | tools: |
| 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 | } |
nothing calls this directly
no test coverage detected