mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-10-19 13:49:53 +00:00
aad99ebcb7
Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.19.0 to 1.20.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.19.0...v1.20.0) --- updated-dependencies: - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package matchers
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/onsi/gomega/format"
|
|
)
|
|
|
|
type HaveExistingFieldMatcher struct {
|
|
Field string
|
|
}
|
|
|
|
func (matcher *HaveExistingFieldMatcher) Match(actual interface{}) (success bool, err error) {
|
|
// we don't care about the field's actual value, just about any error in
|
|
// trying to find the field (or method).
|
|
_, err = extractField(actual, matcher.Field, "HaveExistingField")
|
|
if err == nil {
|
|
return true, nil
|
|
}
|
|
var mferr missingFieldError
|
|
if errors.As(err, &mferr) {
|
|
// missing field errors aren't errors in this context, but instead
|
|
// unsuccessful matches.
|
|
return false, nil
|
|
}
|
|
return false, err
|
|
}
|
|
|
|
func (matcher *HaveExistingFieldMatcher) FailureMessage(actual interface{}) (message string) {
|
|
return fmt.Sprintf("Expected\n%s\nto have field '%s'", format.Object(actual, 1), matcher.Field)
|
|
}
|
|
|
|
func (matcher *HaveExistingFieldMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
|
return fmt.Sprintf("Expected\n%s\nnot to have field '%s'", format.Object(actual, 1), matcher.Field)
|
|
}
|