(t *testing.T)
| 308 | } |
| 309 | |
| 310 | func TestFormatGeneric(t *testing.T) { |
| 311 | starts := []struct { |
| 312 | err error |
| 313 | want []string |
| 314 | }{ |
| 315 | {New("new-error"), []string{ |
| 316 | "new-error", |
| 317 | "github.com/pkg/errors.TestFormatGeneric\n" + |
| 318 | "\t.+/github.com/pkg/errors/format_test.go:315"}, |
| 319 | }, {Errorf("errorf-error"), []string{ |
| 320 | "errorf-error", |
| 321 | "github.com/pkg/errors.TestFormatGeneric\n" + |
| 322 | "\t.+/github.com/pkg/errors/format_test.go:319"}, |
| 323 | }, {errors.New("errors-new-error"), []string{ |
| 324 | "errors-new-error"}, |
| 325 | }, |
| 326 | } |
| 327 | |
| 328 | wrappers := []wrapper{ |
| 329 | { |
| 330 | func(err error) error { return WithMessage(err, "with-message") }, |
| 331 | []string{"with-message"}, |
| 332 | }, { |
| 333 | func(err error) error { return WithStack(err) }, |
| 334 | []string{ |
| 335 | "github.com/pkg/errors.(func·002|TestFormatGeneric.func2)\n\t" + |
| 336 | ".+/github.com/pkg/errors/format_test.go:333", |
| 337 | }, |
| 338 | }, { |
| 339 | func(err error) error { return Wrap(err, "wrap-error") }, |
| 340 | []string{ |
| 341 | "wrap-error", |
| 342 | "github.com/pkg/errors.(func·003|TestFormatGeneric.func3)\n\t" + |
| 343 | ".+/github.com/pkg/errors/format_test.go:339", |
| 344 | }, |
| 345 | }, { |
| 346 | func(err error) error { return Wrapf(err, "wrapf-error%d", 1) }, |
| 347 | []string{ |
| 348 | "wrapf-error1", |
| 349 | "github.com/pkg/errors.(func·004|TestFormatGeneric.func4)\n\t" + |
| 350 | ".+/github.com/pkg/errors/format_test.go:346", |
| 351 | }, |
| 352 | }, |
| 353 | } |
| 354 | |
| 355 | for s := range starts { |
| 356 | err := starts[s].err |
| 357 | want := starts[s].want |
| 358 | testFormatCompleteCompare(t, s, err, "%+v", want, false) |
| 359 | testGenericRecursive(t, err, want, wrappers, 3) |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | func wrappedNew(message string) error { // This function will be mid-stack inlined in go 1.12+ |
| 364 | return New(message) |
nothing calls this directly
no test coverage detected
searching dependent graphs…