MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestFormatErrorList

Function TestFormatErrorList

pkg/errors/formatter_test.go:285–333  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

283}
284
285func TestFormatErrorList(t *testing.T) {
286 tests := []struct {
287 name string
288 errors []*Error
289 contains []string
290 }{
291 {
292 name: "empty list",
293 errors: []*Error{},
294 contains: []string{"No errors"},
295 },
296 {
297 name: "single error",
298 errors: []*Error{
299 NewError(ErrCodeUnexpectedToken, "error 1", models.Location{Line: 1, Column: 1}),
300 },
301 contains: []string{
302 "Found 1 error(s)",
303 "Error 1:",
304 "error 1",
305 },
306 },
307 {
308 name: "multiple errors",
309 errors: []*Error{
310 NewError(ErrCodeUnexpectedToken, "error 1", models.Location{Line: 1, Column: 1}),
311 NewError(ErrCodeExpectedToken, "error 2", models.Location{Line: 2, Column: 5}),
312 },
313 contains: []string{
314 "Found 2 error(s)",
315 "Error 1:",
316 "Error 2:",
317 "error 1",
318 "error 2",
319 },
320 },
321 }
322
323 for _, tt := range tests {
324 t.Run(tt.name, func(t *testing.T) {
325 got := FormatErrorList(tt.errors)
326 for _, substr := range tt.contains {
327 if !strings.Contains(got, substr) {
328 t.Errorf("FormatErrorList() missing substring %q\nGot:\n%s", substr, got)
329 }
330 }
331 })
332 }
333}
334
335func TestFormatErrorWithExample(t *testing.T) {
336 got := FormatErrorWithExample(

Callers

nothing calls this directly

Calls 4

FormatErrorListFunction · 0.85
RunMethod · 0.80
NewErrorFunction · 0.70
ErrorfMethod · 0.65

Tested by

no test coverage detected