@@ -106,6 +106,31 @@ func TestPrintCompilationSummary(t *testing.T) {
106106 FailedWorkflows : []string {"workflow1.md" , "workflow2.md" },
107107 },
108108 },
109+ {
110+ name : "with detailed failure information" ,
111+ stats : & CompilationStats {
112+ Total : 5 ,
113+ Errors : 3 ,
114+ Warnings : 1 ,
115+ FailureDetails : []WorkflowFailure {
116+ {Path : ".github/workflows/test1.md" , ErrorCount : 1 },
117+ {Path : ".github/workflows/test2.md" , ErrorCount : 2 },
118+ {Path : ".github/workflows/test3.md" , ErrorCount : 1 },
119+ },
120+ },
121+ },
122+ {
123+ name : "with multiple errors per workflow" ,
124+ stats : & CompilationStats {
125+ Total : 3 ,
126+ Errors : 5 ,
127+ Warnings : 0 ,
128+ FailureDetails : []WorkflowFailure {
129+ {Path : ".github/workflows/complex.md" , ErrorCount : 3 },
130+ {Path : ".github/workflows/simple.md" , ErrorCount : 2 },
131+ },
132+ },
133+ },
109134 }
110135
111136 for _ , tt := range tests {
@@ -116,6 +141,60 @@ func TestPrintCompilationSummary(t *testing.T) {
116141 }
117142}
118143
144+ // TestTrackWorkflowFailure tests the trackWorkflowFailure helper function
145+ func TestTrackWorkflowFailure (t * testing.T ) {
146+ tests := []struct {
147+ name string
148+ workflowPath string
149+ errorCount int
150+ expectedDetails WorkflowFailure
151+ }{
152+ {
153+ name : "single error" ,
154+ workflowPath : ".github/workflows/test.md" ,
155+ errorCount : 1 ,
156+ expectedDetails : WorkflowFailure {
157+ Path : ".github/workflows/test.md" ,
158+ ErrorCount : 1 ,
159+ },
160+ },
161+ {
162+ name : "multiple errors" ,
163+ workflowPath : ".github/workflows/complex.md" ,
164+ errorCount : 5 ,
165+ expectedDetails : WorkflowFailure {
166+ Path : ".github/workflows/complex.md" ,
167+ ErrorCount : 5 ,
168+ },
169+ },
170+ }
171+
172+ for _ , tt := range tests {
173+ t .Run (tt .name , func (t * testing.T ) {
174+ stats := & CompilationStats {}
175+ trackWorkflowFailure (stats , tt .workflowPath , tt .errorCount )
176+
177+ // Check that FailedWorkflows was updated
178+ if len (stats .FailedWorkflows ) != 1 {
179+ t .Errorf ("Expected 1 failed workflow, got %d" , len (stats .FailedWorkflows ))
180+ }
181+
182+ // Check that FailureDetails was updated correctly
183+ if len (stats .FailureDetails ) != 1 {
184+ t .Errorf ("Expected 1 failure detail, got %d" , len (stats .FailureDetails ))
185+ }
186+
187+ detail := stats .FailureDetails [0 ]
188+ if detail .Path != tt .expectedDetails .Path {
189+ t .Errorf ("Expected path %s, got %s" , tt .expectedDetails .Path , detail .Path )
190+ }
191+ if detail .ErrorCount != tt .expectedDetails .ErrorCount {
192+ t .Errorf ("Expected error count %d, got %d" , tt .expectedDetails .ErrorCount , detail .ErrorCount )
193+ }
194+ })
195+ }
196+ }
197+
119198// Note: TestHandleFileDeleted is already tested in commands_file_watching_test.go
120199
121200// TestCompileWorkflowWithValidation_InvalidFile tests error handling
0 commit comments