github.com/lingyao2333/mo-zero@v1.4.1/core/errorx/callchain_test.go (about) 1 package errorx 2 3 import ( 4 "errors" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestChain(t *testing.T) { 11 errDummy := errors.New("dummy") 12 assert.Nil(t, Chain(func() error { 13 return nil 14 }, func() error { 15 return nil 16 })) 17 assert.Equal(t, errDummy, Chain(func() error { 18 return errDummy 19 }, func() error { 20 return nil 21 })) 22 assert.Equal(t, errDummy, Chain(func() error { 23 return nil 24 }, func() error { 25 return errDummy 26 })) 27 }