(t *testing.T)
| 27 | ) |
| 28 | |
| 29 | func TestOneLineSource(t *testing.T) { |
| 30 | tt := testutils.T{T: t} |
| 31 | |
| 32 | simpleErr := errors.New("hello") |
| 33 | testData := []error{ |
| 34 | withstack.WithStack(simpleErr), |
| 35 | errbase.DecodeError(context.Background(), errbase.EncodeError(context.Background(), withstack.WithStack(simpleErr))), |
| 36 | pkgErr.WithStack(simpleErr), |
| 37 | errbase.DecodeError(context.Background(), errbase.EncodeError(context.Background(), pkgErr.WithStack(simpleErr))), |
| 38 | pkgErr.New("woo"), |
| 39 | errbase.DecodeError(context.Background(), errbase.EncodeError(context.Background(), pkgErr.New("woo"))), |
| 40 | } |
| 41 | |
| 42 | for _, err := range testData { |
| 43 | tt.Run(err.Error(), func(tt testutils.T) { |
| 44 | file, line, fn, ok := withstack.GetOneLineSource(err) |
| 45 | tt.CheckEqual(ok, true) |
| 46 | tt.CheckEqual(file, "one_line_source_test.go") |
| 47 | tt.CheckEqual(fn, "TestOneLineSource") |
| 48 | tt.Check(line > 21) |
| 49 | if tt.Failed() { |
| 50 | tt.Logf("looking at: %+v", err) |
| 51 | } |
| 52 | }) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func TestOneLineSourceInner(t *testing.T) { |
| 57 | tt := testutils.T{T: t} |
nothing calls this directly
no test coverage detected
searching dependent graphs…