MCPcopy Create free account
hub / github.com/github/gh-aw / TestDisplayStatsTable_Exactly10

Function TestDisplayStatsTable_Exactly10

pkg/cli/compile_stats_test.go:76–119  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

74}
75
76func 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
121func TestDisplayStatsTable_MoreThan10(t *testing.T) {
122 // Create test stats with 15 workflows

Callers

nothing calls this directly

Calls 4

displayStatsTableFunction · 0.85
CloseMethod · 0.65
StringMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected