summaryrefslogtreecommitdiff
path: root/vendor/github.com/onsi/gomega/matchers
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2021-05-06 08:07:07 +0000
committerGitHub <noreply@github.com>2021-05-06 08:07:07 +0000
commit3de369fd696e6b98d00259d3c759d9b81df4e84b (patch)
tree7c489ea3aa926cda031d6aaa4a852e9e6e469d14 /vendor/github.com/onsi/gomega/matchers
parent9b9bd9e0e7b72c91d8e60103e8da7999cefbc63d (diff)
downloadpodman-3de369fd696e6b98d00259d3c759d9b81df4e84b.tar.gz
podman-3de369fd696e6b98d00259d3c759d9b81df4e84b.tar.bz2
podman-3de369fd696e6b98d00259d3c759d9b81df4e84b.zip
Bump github.com/onsi/gomega from 1.11.0 to 1.12.0
Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.11.0 to 1.12.0. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.11.0...v1.12.0) Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/github.com/onsi/gomega/matchers')
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go2
-rw-r--r--vendor/github.com/onsi/gomega/matchers/satisfy_matcher.go66
2 files changed, 67 insertions, 1 deletions
diff --git a/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go
index f72591a1a..100735de3 100644
--- a/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go
+++ b/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go
@@ -45,7 +45,7 @@ func (matcher *BeNumericallyMatcher) Match(actual interface{}) (success bool, er
return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[0], 1))
}
if len(matcher.CompareTo) == 2 && !isNumber(matcher.CompareTo[1]) {
- return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[0], 1))
+ return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[1], 1))
}
switch matcher.Comparator {
diff --git a/vendor/github.com/onsi/gomega/matchers/satisfy_matcher.go b/vendor/github.com/onsi/gomega/matchers/satisfy_matcher.go
new file mode 100644
index 000000000..ec68fe8b6
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/satisfy_matcher.go
@@ -0,0 +1,66 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+)
+
+type SatisfyMatcher struct {
+ Predicate interface{}
+
+ // cached type
+ predicateArgType reflect.Type
+}
+
+func NewSatisfyMatcher(predicate interface{}) *SatisfyMatcher {
+ if predicate == nil {
+ panic("predicate cannot be nil")
+ }
+ predicateType := reflect.TypeOf(predicate)
+ if predicateType.Kind() != reflect.Func {
+ panic("predicate must be a function")
+ }
+ if predicateType.NumIn() != 1 {
+ panic("predicate must have 1 argument")
+ }
+ if predicateType.NumOut() != 1 || predicateType.Out(0).Kind() != reflect.Bool {
+ panic("predicate must return bool")
+ }
+
+ return &SatisfyMatcher{
+ Predicate: predicate,
+ predicateArgType: predicateType.In(0),
+ }
+}
+
+func (m *SatisfyMatcher) Match(actual interface{}) (success bool, err error) {
+ // prepare a parameter to pass to the predicate
+ var param reflect.Value
+ if actual != nil && reflect.TypeOf(actual).AssignableTo(m.predicateArgType) {
+ // The dynamic type of actual is compatible with the predicate argument.
+ param = reflect.ValueOf(actual)
+
+ } else if actual == nil && m.predicateArgType.Kind() == reflect.Interface {
+ // The dynamic type of actual is unknown, so there's no way to make its
+ // reflect.Value. Create a nil of the predicate argument, which is known.
+ param = reflect.Zero(m.predicateArgType)
+
+ } else {
+ return false, fmt.Errorf("predicate expects '%s' but we have '%T'", m.predicateArgType, actual)
+ }
+
+ // call the predicate with `actual`
+ fn := reflect.ValueOf(m.Predicate)
+ result := fn.Call([]reflect.Value{param})
+ return result[0].Bool(), nil
+}
+
+func (m *SatisfyMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to satisfy predicate", m.Predicate)
+}
+
+func (m *SatisfyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to not satisfy predicate", m.Predicate)
+}