errors_test.go 360 B

1234567891011121314151617181920
  1. package xerr
  2. import (
  3. "errors"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func Test_withStack_Unwrap(t *testing.T) {
  8. err := &CustomError{msg: "test error"}
  9. stackErr := WithStack(err)
  10. assert.NotEqual(t, stackErr, err)
  11. assert.Equal(t, errors.Unwrap(stackErr), err)
  12. assert.True(t, errors.Is(stackErr, err))
  13. assert.ErrorIs(t, stackErr, err)
  14. }