Fix bad recursion in errdefs check

This commit is contained in:
Brian Goff
2019-06-04 15:06:41 -07:00
parent 20e710043f
commit f414dc8bf2
4 changed files with 10 additions and 6 deletions

View File

@@ -58,7 +58,7 @@ func IsInvalidInput(err error) bool {
}
if e, ok := err.(causal); ok {
return IsInvalidInput(e)
return IsInvalidInput(e.Cause())
}
return false

View File

@@ -1,10 +1,10 @@
package errdefs
import (
"errors"
"fmt"
"testing"
"github.com/pkg/errors"
"gotest.tools/assert"
"gotest.tools/assert/cmp"
)
@@ -76,5 +76,7 @@ func TestIsInvalidInput(t *testing.T) {
func TestInvalidInputCause(t *testing.T) {
err := errors.New("test")
assert.Equal(t, (&invalidInputError{err}).Cause(), err)
e := &invalidInputError{err}
assert.Check(t, cmp.Equal(e.Cause(), err))
assert.Check(t, IsInvalidInput(errors.Wrap(e, "some details")))
}

View File

@@ -58,7 +58,7 @@ func IsNotFound(err error) bool {
}
if e, ok := err.(causal); ok {
return IsNotFound(e)
return IsNotFound(e.Cause())
}
return false

View File

@@ -1,10 +1,10 @@
package errdefs
import (
"errors"
"fmt"
"testing"
"github.com/pkg/errors"
"gotest.tools/assert"
"gotest.tools/assert/cmp"
)
@@ -76,5 +76,7 @@ func TestIsNotFound(t *testing.T) {
func TestNotFoundCause(t *testing.T) {
err := errors.New("test")
assert.Equal(t, (&notFoundError{err}).Cause(), err)
e := &notFoundError{err}
assert.Check(t, cmp.Equal(e.Cause(), err))
assert.Check(t, IsNotFound(errors.Wrap(e, "some details")))
}