(t *testing.T)
| 54 | } |
| 55 | |
| 56 | func TestOneLineSourceInner(t *testing.T) { |
| 57 | tt := testutils.T{T: t} |
| 58 | |
| 59 | // makeErr creates an error where the source context is not this |
| 60 | // test function. |
| 61 | simpleErr := makeErr() |
| 62 | |
| 63 | // Make the error wrapped to add additional source context. The rest |
| 64 | // of the test below will check that GetOneLineSource retrieves the |
| 65 | // innermost context, not this one. |
| 66 | testData := []error{ |
| 67 | withstack.WithStack(simpleErr), |
| 68 | errbase.DecodeError(context.Background(), errbase.EncodeError(context.Background(), withstack.WithStack(simpleErr))), |
| 69 | pkgErr.WithStack(simpleErr), |
| 70 | errbase.DecodeError(context.Background(), errbase.EncodeError(context.Background(), pkgErr.WithStack(simpleErr))), |
| 71 | } |
| 72 | |
| 73 | for _, err := range testData { |
| 74 | file, line, fn, ok := withstack.GetOneLineSource(err) |
| 75 | tt.CheckEqual(ok, true) |
| 76 | tt.CheckEqual(file, "reportable_test.go") |
| 77 | tt.Check(strings.HasPrefix(fn, "makeErr")) |
| 78 | tt.Check(line > 21) |
| 79 | } |
| 80 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…