wrap_test.go 382 B

123456789101112131415161718
  1. package errorx
  2. import (
  3. "errors"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestWrap(t *testing.T) {
  8. assert.Nil(t, Wrap(nil, "test"))
  9. assert.Equal(t, "foo: bar", Wrap(errors.New("bar"), "foo").Error())
  10. }
  11. func TestWrapf(t *testing.T) {
  12. assert.Nil(t, Wrapf(nil, "%s", "test"))
  13. assert.Equal(t, "foo bar: quz", Wrapf(errors.New("quz"), "foo %s", "bar").Error())
  14. }