callchain_test.go 449 B

123456789101112131415161718192021222324252627
  1. package errorx
  2. import (
  3. "errors"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestChain(t *testing.T) {
  8. var errDummy = errors.New("dummy")
  9. assert.Nil(t, Chain(func() error {
  10. return nil
  11. }, func() error {
  12. return nil
  13. }))
  14. assert.Equal(t, errDummy, Chain(func() error {
  15. return errDummy
  16. }, func() error {
  17. return nil
  18. }))
  19. assert.Equal(t, errDummy, Chain(func() error {
  20. return nil
  21. }, func() error {
  22. return errDummy
  23. }))
  24. }