xerr_test.go 453 B

12345678910111213141516171819202122232425
  1. package xerr
  2. import (
  3. "io"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestMyWrap(t *testing.T) {
  8. assert.Error(t, foo())
  9. assert.Error(t, Wrap(foo(), "wrap_foo"))
  10. assert.Error(t, WrapWithLog(foo(), "wrap_foo_log"))
  11. assert.Error(t, Wrap(io.EOF))
  12. assert.Error(t, WrapWithLog(io.EOF))
  13. assert.Error(t, WithMessage(foo()))
  14. assert.Error(t, WithMessage(foo(), "with message"))
  15. }
  16. func foo() error {
  17. return Wrap(io.EOF, "read file")
  18. }