diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2021-03-08 08:54:47 -0500 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2021-03-08 08:54:47 -0500 |
commit | 7e289833ed96c96ca3cdc4ed0a82ddd1caa0dc26 (patch) | |
tree | fb218880756a01149fc72d5362495ea8de6a3ffe /vendor/github.com/onsi/gomega/matchers/with_transform.go | |
parent | 6fe634c9165367ecf797794f016dd640bc28ff2f (diff) | |
download | podman-7e289833ed96c96ca3cdc4ed0a82ddd1caa0dc26.tar.gz podman-7e289833ed96c96ca3cdc4ed0a82ddd1caa0dc26.tar.bz2 podman-7e289833ed96c96ca3cdc4ed0a82ddd1caa0dc26.zip |
Bump github.com/onsi/gomega from 1.10.5 to 1.11.0
Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.10.5 to 1.11.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.10.5...v1.11.0)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/onsi/gomega/matchers/with_transform.go')
-rw-r--r-- | vendor/github.com/onsi/gomega/matchers/with_transform.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/vendor/github.com/onsi/gomega/matchers/with_transform.go b/vendor/github.com/onsi/gomega/matchers/with_transform.go index 8e58d8a0f..f3dec9101 100644 --- a/vendor/github.com/onsi/gomega/matchers/with_transform.go +++ b/vendor/github.com/onsi/gomega/matchers/with_transform.go @@ -40,15 +40,24 @@ func NewWithTransformMatcher(transform interface{}, matcher types.GomegaMatcher) } func (m *WithTransformMatcher) Match(actual interface{}) (bool, error) { - // return error if actual's type is incompatible with Transform function's argument type - actualType := reflect.TypeOf(actual) - if !actualType.AssignableTo(m.transformArgType) { - return false, fmt.Errorf("Transform function expects '%s' but we have '%s'", m.transformArgType, actualType) + // prepare a parameter to pass to the Transform function + var param reflect.Value + if actual != nil && reflect.TypeOf(actual).AssignableTo(m.transformArgType) { + // The dynamic type of actual is compatible with the transform argument. + param = reflect.ValueOf(actual) + + } else if actual == nil && m.transformArgType.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 transform argument, which is known. + param = reflect.Zero(m.transformArgType) + + } else { + return false, fmt.Errorf("Transform function expects '%s' but we have '%T'", m.transformArgType, actual) } // call the Transform function with `actual` fn := reflect.ValueOf(m.Transform) - result := fn.Call([]reflect.Value{reflect.ValueOf(actual)}) + result := fn.Call([]reflect.Value{param}) m.transformedValue = result[0].Interface() // expect exactly one value return m.Matcher.Match(m.transformedValue) |