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

Function TestErrorCollectorFormattedError

pkg/workflow/error_aggregation_test.go:210–282  ·  view source on GitHub ↗

TestErrorCollectorFormattedError tests the FormattedError method

(t *testing.T)

Source from the content-addressed store, hash-verified

208
209// TestErrorCollectorFormattedError tests the FormattedError method
210func TestErrorCollectorFormattedError(t *testing.T) {
211 tests := []struct {
212 name string
213 errors []error
214 category string
215 expectError bool
216 shouldContain []string
217 }{
218 {
219 name: "no errors",
220 errors: []error{},
221 category: "validation",
222 expectError: false,
223 },
224 {
225 name: "single error (no formatting)",
226 errors: []error{errors.New("single error")},
227 category: "validation",
228 expectError: true,
229 shouldContain: []string{"single error"},
230 },
231 {
232 name: "multiple errors with formatted header",
233 errors: []error{errors.New("error 1"), errors.New("error 2"), errors.New("error 3")},
234 category: "validation",
235 expectError: true,
236 shouldContain: []string{
237 "Found 3 validation errors:",
238 "error 1",
239 "error 2",
240 "error 3",
241 },
242 },
243 {
244 name: "errors with newlines preserved",
245 errors: []error{errors.New("error with\nmultiple\nlines"), errors.New("simple error")},
246 category: "test",
247 expectError: true,
248 shouldContain: []string{
249 "Found 2 test errors:",
250 "error with",
251 "multiple",
252 "lines",
253 "simple error",
254 },
255 },
256 }
257
258 for _, tt := range tests {
259 t.Run(tt.name, func(t *testing.T) {
260 collector := NewErrorCollector(false)
261
262 // Add all errors
263 for _, err := range tt.errors {
264 _ = collector.Add(err)
265 }
266
267 // Get the formatted error

Callers

nothing calls this directly

Calls 5

AddMethod · 0.95
FormattedErrorMethod · 0.95
NewErrorCollectorFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected