(t *testing.T)
| 32 | } |
| 33 | |
| 34 | func TestDisplayStatsTable_LessThan10(t *testing.T) { |
| 35 | // Create test stats with 5 workflows |
| 36 | statsList := []*WorkflowStats{ |
| 37 | {Workflow: "workflow1.lock.yml", FileSize: 5000, Jobs: 5, Steps: 10, ScriptCount: 8}, |
| 38 | {Workflow: "workflow2.lock.yml", FileSize: 4000, Jobs: 4, Steps: 8, ScriptCount: 6}, |
| 39 | {Workflow: "workflow3.lock.yml", FileSize: 3000, Jobs: 3, Steps: 6, ScriptCount: 4}, |
| 40 | {Workflow: "workflow4.lock.yml", FileSize: 2000, Jobs: 2, Steps: 4, ScriptCount: 2}, |
| 41 | {Workflow: "workflow5.lock.yml", FileSize: 1000, Jobs: 1, Steps: 2, ScriptCount: 1}, |
| 42 | } |
| 43 | |
| 44 | // Capture stderr output |
| 45 | oldStderr := os.Stderr |
| 46 | r, w, _ := os.Pipe() |
| 47 | os.Stderr = w |
| 48 | |
| 49 | displayStatsTable(statsList) |
| 50 | |
| 51 | w.Close() |
| 52 | os.Stderr = oldStderr |
| 53 | |
| 54 | var buf bytes.Buffer |
| 55 | buf.ReadFrom(r) |
| 56 | output := buf.String() |
| 57 | |
| 58 | // Should show all 5 workflows |
| 59 | for _, stats := range statsList { |
| 60 | if !strings.Contains(output, stats.Workflow) { |
| 61 | t.Errorf("Expected workflow %s to be displayed, but it wasn't found", stats.Workflow) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | // Should show "Total workflows: 5" |
| 66 | if !strings.Contains(output, "Total workflows: 5") { |
| 67 | t.Errorf("Expected 'Total workflows: 5' in output, got: %s", output) |
| 68 | } |
| 69 | |
| 70 | // Should NOT show "Showing top X of Y" message |
| 71 | if strings.Contains(output, "Showing top") { |
| 72 | t.Errorf("Should not show truncation message for 5 workflows, got: %s", output) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | func TestDisplayStatsTable_Exactly10(t *testing.T) { |
| 77 | // Create test stats with exactly 10 workflows |
nothing calls this directly
no test coverage detected