MCPcopy Index your code
hub / github.com/cockroachdb/errors / TestOneLineSourceInner

Function TestOneLineSourceInner

withstack/one_line_source_test.go:56–80  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

54}
55
56func 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}

Callers

nothing calls this directly

Calls 7

CheckEqualMethod · 0.95
CheckMethod · 0.95
WithStackFunction · 0.92
DecodeErrorFunction · 0.92
EncodeErrorFunction · 0.92
GetOneLineSourceFunction · 0.92
makeErrFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…