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

Function TestAssert

assert/assert_test.go:31–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29)
30
31func TestAssert(t *testing.T) {
32 tt := testutils.T{T: t}
33
34 baseErr := errors.New("world")
35 err := errors.Wrap(assert.WithAssertionFailure(baseErr), "hello")
36
37 tt.Check(markers.Is(err, baseErr))
38
39 tt.Check(assert.HasAssertionFailure(err))
40
41 if _, ok := markers.If(err, func(err error) (interface{}, bool) { return nil, assert.IsAssertionFailure(err) }); !ok {
42 t.Error("woops")
43 }
44
45 tt.CheckEqual(err.Error(), "hello: world")
46
47 enc := errbase.EncodeError(context.Background(), err)
48 newErr := errbase.DecodeError(context.Background(), enc)
49
50 tt.Check(markers.Is(newErr, baseErr))
51
52 tt.Check(assert.HasAssertionFailure(newErr))
53
54 if _, ok := markers.If(newErr, func(err error) (interface{}, bool) { return nil, assert.IsAssertionFailure(err) }); !ok {
55 t.Error("woops")
56 }
57
58 tt.CheckEqual(newErr.Error(), "hello: world")
59}
60
61func TestFormat(t *testing.T) {
62 tt := testutils.T{t}

Callers

nothing calls this directly

Calls 10

CheckMethod · 0.95
CheckEqualMethod · 0.95
WithAssertionFailureFunction · 0.92
IsFunction · 0.92
HasAssertionFailureFunction · 0.92
IfFunction · 0.92
IsAssertionFailureFunction · 0.92
EncodeErrorFunction · 0.92
DecodeErrorFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…