(t *testing.T)
| 133 | } |
| 134 | |
| 135 | func TestGetRequiredSecretsForWorkflows(t *testing.T) { |
| 136 | t.Run("collects secrets from multiple workflows", func(t *testing.T) { |
| 137 | // Create a temporary directory with test workflow files |
| 138 | tempDir := t.TempDir() |
| 139 | workflowsDir := filepath.Join(tempDir, ".github", "workflows") |
| 140 | err := os.MkdirAll(workflowsDir, 0755) |
| 141 | require.NoError(t, err, "Should create workflows directory") |
| 142 | |
| 143 | // Create test workflow files with different engines |
| 144 | testWorkflows := map[string]string{ |
| 145 | "copilot-workflow.md": `--- |
| 146 | engine: copilot |
| 147 | on: push |
| 148 | --- |
| 149 | # Copilot Workflow`, |
| 150 | "claude-workflow.md": `--- |
| 151 | engine: claude |
| 152 | on: pull_request |
| 153 | --- |
| 154 | # Claude Workflow`, |
| 155 | "codex-workflow.md": `--- |
| 156 | engine: codex |
| 157 | on: workflow_dispatch |
| 158 | --- |
| 159 | # Codex Workflow`, |
| 160 | } |
| 161 | |
| 162 | var workflowFiles []string |
| 163 | for filename, content := range testWorkflows { |
| 164 | path := filepath.Join(workflowsDir, filename) |
| 165 | err := os.WriteFile(path, []byte(content), 0644) |
| 166 | require.NoError(t, err, "Should write workflow file %s", filename) |
| 167 | workflowFiles = append(workflowFiles, path) |
| 168 | } |
| 169 | |
| 170 | // Test the function |
| 171 | secrets := getSecretsRequirementsForWorkflows(workflowFiles) |
| 172 | |
| 173 | require.NotEmpty(t, secrets, "Should return secrets") |
| 174 | |
| 175 | // Convert to map for easy checking |
| 176 | secretMap := make(map[string]SecretRequirement) |
| 177 | for _, secret := range secrets { |
| 178 | secretMap[secret.Name] = secret |
| 179 | } |
| 180 | |
| 181 | // Check engine secrets |
| 182 | assert.Contains(t, secretMap, "COPILOT_GITHUB_TOKEN", "Should include Copilot secret") |
| 183 | assert.Contains(t, secretMap, "ANTHROPIC_API_KEY", "Should include Claude secret") |
| 184 | assert.Contains(t, secretMap, "OPENAI_API_KEY", "Should include Codex secret") |
| 185 | |
| 186 | // Check system secrets are included |
| 187 | for _, sys := range constants.SystemSecrets { |
| 188 | assert.Contains(t, secretMap, sys.Name, "Should include system secret %s", sys.Name) |
| 189 | } |
| 190 | |
| 191 | // Verify no duplicates |
| 192 | assert.Len(t, secrets, len(secretMap), "Should not have duplicate secrets") |
nothing calls this directly
no test coverage detected