(t *testing.T)
| 74 | } |
| 75 | |
| 76 | func TestDisplayStatsTable_Exactly10(t *testing.T) { |
| 77 | // Create test stats with exactly 10 workflows |
| 78 | statsList := make([]*WorkflowStats, 10) |
| 79 | for i := range 10 { |
| 80 | statsList[i] = &WorkflowStats{ |
| 81 | Workflow: fmt.Sprintf("workflow%d.lock.yml", i+1), |
| 82 | FileSize: int64((10 - i) * 1000), // Descending sizes |
| 83 | Jobs: 10 - i, |
| 84 | Steps: (10 - i) * 2, |
| 85 | ScriptCount: (10 - i) * 3, |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | // Capture stderr output |
| 90 | oldStderr := os.Stderr |
| 91 | r, w, _ := os.Pipe() |
| 92 | os.Stderr = w |
| 93 | |
| 94 | displayStatsTable(statsList) |
| 95 | |
| 96 | w.Close() |
| 97 | os.Stderr = oldStderr |
| 98 | |
| 99 | var buf bytes.Buffer |
| 100 | buf.ReadFrom(r) |
| 101 | output := buf.String() |
| 102 | |
| 103 | // Should show all 10 workflows |
| 104 | for _, stats := range statsList { |
| 105 | if !strings.Contains(output, stats.Workflow) { |
| 106 | t.Errorf("Expected workflow %s to be displayed, but it wasn't found", stats.Workflow) |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | // Should show "Total workflows: 10" |
| 111 | if !strings.Contains(output, "Total workflows: 10") { |
| 112 | t.Errorf("Expected 'Total workflows: 10' in output, got: %s", output) |
| 113 | } |
| 114 | |
| 115 | // Should NOT show "Showing top X of Y" message |
| 116 | if strings.Contains(output, "Showing top") { |
| 117 | t.Errorf("Should not show truncation message for exactly 10 workflows, got: %s", output) |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | func TestDisplayStatsTable_MoreThan10(t *testing.T) { |
| 122 | // Create test stats with 15 workflows |
nothing calls this directly
no test coverage detected