chore: add more tests (#2129)

master
Kevin Wan 2 years ago committed by GitHub
parent d71b3c841f
commit 23f34234d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,9 +10,15 @@ import (
func TestWrap(t *testing.T) { func TestWrap(t *testing.T) {
assert.Nil(t, Wrap(nil, "test")) assert.Nil(t, Wrap(nil, "test"))
assert.Equal(t, "foo: bar", Wrap(errors.New("bar"), "foo").Error()) assert.Equal(t, "foo: bar", Wrap(errors.New("bar"), "foo").Error())
err := errors.New("foo")
assert.True(t, errors.Is(Wrap(err, "bar"), err))
} }
func TestWrapf(t *testing.T) { func TestWrapf(t *testing.T) {
assert.Nil(t, Wrapf(nil, "%s", "test")) assert.Nil(t, Wrapf(nil, "%s", "test"))
assert.Equal(t, "foo bar: quz", Wrapf(errors.New("quz"), "foo %s", "bar").Error()) assert.Equal(t, "foo bar: quz", Wrapf(errors.New("quz"), "foo %s", "bar").Error())
err := errors.New("foo")
assert.True(t, errors.Is(Wrapf(err, "foo %s", "bar"), err))
} }

Loading…
Cancel
Save