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

Function TestDisplayStatsTable_LessThan10

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

Source from the content-addressed store, hash-verified

32}
33
34func 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
76func TestDisplayStatsTable_Exactly10(t *testing.T) {
77 // Create test stats with exactly 10 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