MCPcopy
hub / github.com/duke-git/lancet / TestCatch

Function TestCatch

promise/promise_test.go:78–103  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

76}
77
78func TestCatch(t *testing.T) {
79 t.Parallel()
80
81 assert := internal.NewAssert(t, "TestCatch")
82
83 p1 := New(func(resolve func(string), reject func(error)) {
84 err := errors.New("error1")
85 reject(err)
86 })
87
88 p2 := Catch(p1, func(err error) error {
89 e := errors.New("error2")
90 return internal.JoinError(err, e)
91 })
92
93 val, err := p1.Await()
94 assert.Equal("", val)
95 assert.IsNotNil(err)
96 assert.Equal("error1", err.Error())
97
98 val, err = p2.Await()
99
100 assert.Equal("", val)
101 assert.IsNotNil(err)
102 assert.Equal("error1\nerror2", err.Error())
103}
104
105func TestPromise_Catch(t *testing.T) {
106 t.Parallel()

Callers

nothing calls this directly

Calls 9

EqualMethod · 0.95
IsNotNilMethod · 0.95
NewAssertFunction · 0.92
JoinErrorFunction · 0.92
CatchFunction · 0.85
NewMethod · 0.80
AwaitMethod · 0.80
NewFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…