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

Function TestOneLineSource

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

Source from the content-addressed store, hash-verified

27)
28
29func 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
56func TestOneLineSourceInner(t *testing.T) {
57 tt := testutils.T{T: t}

Callers

nothing calls this directly

Calls 8

RunMethod · 0.95
CheckEqualMethod · 0.95
CheckMethod · 0.95
WithStackFunction · 0.92
DecodeErrorFunction · 0.92
EncodeErrorFunction · 0.92
GetOneLineSourceFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…