TestWorkflowCounting tests that only user workflows are counted and displayed
(t *testing.T)
| 14 | |
| 15 | // TestWorkflowCounting tests that only user workflows are counted and displayed |
| 16 | func TestWorkflowCounting(t *testing.T) { |
| 17 | // This test verifies that internal workflows (those without .md files) are hidden from users |
| 18 | // Only workflows with .md source files are counted and displayed |
| 19 | |
| 20 | // Save current directory |
| 21 | originalDir, err := os.Getwd() |
| 22 | require.NoError(t, err, "Should get current directory") |
| 23 | |
| 24 | // Change to repository root |
| 25 | repoRoot := filepath.Join(originalDir, "..", "..") |
| 26 | err = os.Chdir(repoRoot) |
| 27 | require.NoError(t, err, "Should change to repository root") |
| 28 | defer os.Chdir(originalDir) |
| 29 | |
| 30 | // Get markdown workflow files (simulating what fetchGitHubWorkflows does) |
| 31 | mdFiles, err := getMarkdownWorkflowFiles("") |
| 32 | if err != nil { |
| 33 | t.Skipf("Skipping test: no .github/workflows directory found: %v", err) |
| 34 | } |
| 35 | |
| 36 | // Build set of workflow names from .md files |
| 37 | mdWorkflowNames := make(map[string]bool) |
| 38 | for _, file := range mdFiles { |
| 39 | name := extractWorkflowNameFromPath(file) |
| 40 | mdWorkflowNames[name] = true |
| 41 | } |
| 42 | |
| 43 | // We should have at least some .md files |
| 44 | assert.NotEmpty(t, mdWorkflowNames, "Should have at least some .md workflow files") |
| 45 | |
| 46 | // Simulate having some GitHub workflows where not all have .md files |
| 47 | // (in reality, this would come from GitHub API) |
| 48 | simulatedGitHubWorkflows := make(map[string]*GitHubWorkflow) |
| 49 | |
| 50 | // Add all the .md workflows as "user workflows" |
| 51 | for name := range mdWorkflowNames { |
| 52 | simulatedGitHubWorkflows[name] = &GitHubWorkflow{ |
| 53 | Name: name, |
| 54 | Path: ".github/workflows/" + name + ".lock.yml", |
| 55 | State: "active", |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | // Add some internal workflows (those without .md files) |
| 60 | internalWorkflows := []string{"agentics-maintenance", "ci", "auto-close-parent-issues"} |
| 61 | for _, name := range internalWorkflows { |
| 62 | // Only add if not already present (to avoid duplicates) |
| 63 | if !mdWorkflowNames[name] { |
| 64 | simulatedGitHubWorkflows[name] = &GitHubWorkflow{ |
| 65 | Name: name, |
| 66 | Path: ".github/workflows/" + name + ".yml", |
| 67 | State: "active", |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | // Count user workflows only (internal workflows are not displayed to users) |
| 73 | var userWorkflowCount int |
nothing calls this directly
no test coverage detected