summaryrefslogtreecommitdiff
path: root/vendor/github.com/onsi/gomega/matchers
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/onsi/gomega/matchers')
-rw-r--r--vendor/github.com/onsi/gomega/matchers/match_error_matcher.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go b/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go
index 07499ac95..4e09239ff 100644
--- a/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go
+++ b/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go
@@ -5,6 +5,7 @@ import (
"reflect"
"github.com/onsi/gomega/format"
+ "golang.org/x/xerrors"
)
type MatchErrorMatcher struct {
@@ -21,25 +22,28 @@ func (matcher *MatchErrorMatcher) Match(actual interface{}) (success bool, err e
}
actualErr := actual.(error)
+ expected := matcher.Expected
- if isError(matcher.Expected) {
- return reflect.DeepEqual(actualErr, matcher.Expected), nil
+ if isError(expected) {
+ return reflect.DeepEqual(actualErr, expected) || xerrors.Is(actualErr, expected.(error)), nil
}
- if isString(matcher.Expected) {
- return actualErr.Error() == matcher.Expected, nil
+ if isString(expected) {
+ return actualErr.Error() == expected, nil
}
var subMatcher omegaMatcher
var hasSubMatcher bool
- if matcher.Expected != nil {
- subMatcher, hasSubMatcher = (matcher.Expected).(omegaMatcher)
+ if expected != nil {
+ subMatcher, hasSubMatcher = (expected).(omegaMatcher)
if hasSubMatcher {
return subMatcher.Match(actualErr.Error())
}
}
- return false, fmt.Errorf("MatchError must be passed an error, string, or Matcher that can match on strings. Got:\n%s", format.Object(matcher.Expected, 1))
+ return false, fmt.Errorf(
+ "MatchError must be passed an error, a string, or a Matcher that can match on strings. Got:\n%s",
+ format.Object(expected, 1))
}
func (matcher *MatchErrorMatcher) FailureMessage(actual interface{}) (message string) {