mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rebase: bump github.com/onsi/gomega from 1.19.0 to 1.20.0
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>
This commit is contained in:
committed by
mergify[bot]
parent
6e100dde2d
commit
aad99ebcb7
23
vendor/github.com/onsi/gomega/CHANGELOG.md
generated
vendored
23
vendor/github.com/onsi/gomega/CHANGELOG.md
generated
vendored
@ -1,3 +1,26 @@
|
||||
## 1.20.0
|
||||
|
||||
## Features
|
||||
- New [`gleak`](https://onsi.github.io/gomega/#codegleakcode-finding-leaked-goroutines) experimental goroutine leak detection package! (#538) [85ba7bc]
|
||||
- New `BeComparableTo` matcher(#546) that uses `gocmp` to make comparisons [e77ea75]
|
||||
- New `HaveExistingField` matcher (#553) [fd130e1]
|
||||
- Document how to wrap Gomega (#539) [56714a4]
|
||||
|
||||
## Fixes
|
||||
- Support pointer receivers in HaveField; fixes #543 (#544) [8dab36e]
|
||||
|
||||
## Maintenance
|
||||
- Bump various dependencies:
|
||||
- Upgrade to yaml.v3 (#556) [f5a83b1]
|
||||
- Bump github/codeql-action from 1 to 2 (#549) [52f5adf]
|
||||
- Bump github.com/google/go-cmp from 0.5.7 to 0.5.8 (#551) [5f3942d]
|
||||
- Bump nokogiri from 1.13.4 to 1.13.6 in /docs (#554) [eb4b4c2]
|
||||
- Use latest ginkgo (#535) [1c29028]
|
||||
- Bump nokogiri from 1.13.3 to 1.13.4 in /docs (#541) [1ce84d5]
|
||||
- Bump actions/setup-go from 2 to 3 (#540) [755485e]
|
||||
- Bump nokogiri from 1.12.5 to 1.13.3 in /docs (#522) [4fbb0dc]
|
||||
- Bump actions/checkout from 2 to 3 (#526) [ac49202]
|
||||
|
||||
## 1.19.0
|
||||
|
||||
## Features
|
||||
|
2
vendor/github.com/onsi/gomega/gomega_dsl.go
generated
vendored
2
vendor/github.com/onsi/gomega/gomega_dsl.go
generated
vendored
@ -22,7 +22,7 @@ import (
|
||||
"github.com/onsi/gomega/types"
|
||||
)
|
||||
|
||||
const GOMEGA_VERSION = "1.19.0"
|
||||
const GOMEGA_VERSION = "1.20.0"
|
||||
|
||||
const nilGomegaPanic = `You are trying to make an assertion, but haven't registered Gomega's fail handler.
|
||||
If you're using Ginkgo then you probably forgot to put your assertion in an It().
|
||||
|
23
vendor/github.com/onsi/gomega/matchers.go
generated
vendored
23
vendor/github.com/onsi/gomega/matchers.go
generated
vendored
@ -3,6 +3,7 @@ package gomega
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/onsi/gomega/matchers"
|
||||
"github.com/onsi/gomega/types"
|
||||
)
|
||||
@ -26,6 +27,15 @@ func BeEquivalentTo(expected interface{}) types.GomegaMatcher {
|
||||
}
|
||||
}
|
||||
|
||||
//BeComparableTo uses gocmp.Equal to compare. You can pass cmp.Option as options.
|
||||
//It is an error for actual and expected to be nil. Use BeNil() instead.
|
||||
func BeComparableTo(expected interface{}, opts ...cmp.Option) types.GomegaMatcher {
|
||||
return &matchers.BeComparableToMatcher{
|
||||
Expected: expected,
|
||||
Options: opts,
|
||||
}
|
||||
}
|
||||
|
||||
//BeIdenticalTo uses the == operator to compare actual with expected.
|
||||
//BeIdenticalTo is strict about types when performing comparisons.
|
||||
//It is an error for both actual and expected to be nil. Use BeNil() instead.
|
||||
@ -394,6 +404,19 @@ func HaveField(field string, expected interface{}) types.GomegaMatcher {
|
||||
}
|
||||
}
|
||||
|
||||
// HaveExistingField succeeds if actual is a struct and the specified field
|
||||
// exists.
|
||||
//
|
||||
// HaveExistingField can be combined with HaveField in order to cover use cases
|
||||
// with optional fields. HaveField alone would trigger an error in such situations.
|
||||
//
|
||||
// Expect(MrHarmless).NotTo(And(HaveExistingField("Title"), HaveField("Title", "Supervillain")))
|
||||
func HaveExistingField(field string) types.GomegaMatcher {
|
||||
return &matchers.HaveExistingFieldMatcher{
|
||||
Field: field,
|
||||
}
|
||||
}
|
||||
|
||||
// HaveValue applies the given matcher to the value of actual, optionally and
|
||||
// repeatedly dereferencing pointers or taking the concrete value of interfaces.
|
||||
// Thus, the matcher will always be applied to non-pointer and non-interface
|
||||
|
49
vendor/github.com/onsi/gomega/matchers/be_comparable_to_matcher.go
generated
vendored
Normal file
49
vendor/github.com/onsi/gomega/matchers/be_comparable_to_matcher.go
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
package matchers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/onsi/gomega/format"
|
||||
)
|
||||
|
||||
type BeComparableToMatcher struct {
|
||||
Expected interface{}
|
||||
Options cmp.Options
|
||||
}
|
||||
|
||||
func (matcher *BeComparableToMatcher) Match(actual interface{}) (success bool, matchErr error) {
|
||||
if actual == nil && matcher.Expected == nil {
|
||||
return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
|
||||
}
|
||||
// Shortcut for byte slices.
|
||||
// Comparing long byte slices with reflect.DeepEqual is very slow,
|
||||
// so use bytes.Equal if actual and expected are both byte slices.
|
||||
if actualByteSlice, ok := actual.([]byte); ok {
|
||||
if expectedByteSlice, ok := matcher.Expected.([]byte); ok {
|
||||
return bytes.Equal(actualByteSlice, expectedByteSlice), nil
|
||||
}
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
success = false
|
||||
if err, ok := r.(error); ok {
|
||||
matchErr = err
|
||||
} else if errMsg, ok := r.(string); ok {
|
||||
matchErr = fmt.Errorf(errMsg)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return cmp.Equal(actual, matcher.Expected, matcher.Options...), nil
|
||||
}
|
||||
|
||||
func (matcher *BeComparableToMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
return cmp.Diff(matcher.Expected, actual, matcher.Options)
|
||||
}
|
||||
|
||||
func (matcher *BeComparableToMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "not to equal", matcher.Expected)
|
||||
}
|
36
vendor/github.com/onsi/gomega/matchers/have_existing_field_matcher.go
generated
vendored
Normal file
36
vendor/github.com/onsi/gomega/matchers/have_existing_field_matcher.go
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
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)
|
||||
}
|
28
vendor/github.com/onsi/gomega/matchers/have_field.go
generated
vendored
28
vendor/github.com/onsi/gomega/matchers/have_field.go
generated
vendored
@ -8,7 +8,16 @@ import (
|
||||
"github.com/onsi/gomega/format"
|
||||
)
|
||||
|
||||
func extractField(actual interface{}, field string) (interface{}, error) {
|
||||
// missingFieldError represents a missing field extraction error that
|
||||
// HaveExistingFieldMatcher can ignore, as opposed to other, sever field
|
||||
// extraction errors, such as nil pointers, et cetera.
|
||||
type missingFieldError string
|
||||
|
||||
func (e missingFieldError) Error() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func extractField(actual interface{}, field string, matchername string) (interface{}, error) {
|
||||
fields := strings.SplitN(field, ".", 2)
|
||||
actualValue := reflect.ValueOf(actual)
|
||||
|
||||
@ -16,36 +25,39 @@ func extractField(actual interface{}, field string) (interface{}, error) {
|
||||
actualValue = actualValue.Elem()
|
||||
}
|
||||
if actualValue == (reflect.Value{}) {
|
||||
return nil, fmt.Errorf("HaveField encountered nil while dereferencing a pointer of type %T.", actual)
|
||||
return nil, fmt.Errorf("%s encountered nil while dereferencing a pointer of type %T.", matchername, actual)
|
||||
}
|
||||
|
||||
if actualValue.Kind() != reflect.Struct {
|
||||
return nil, fmt.Errorf("HaveField encountered:\n%s\nWhich is not a struct.", format.Object(actual, 1))
|
||||
return nil, fmt.Errorf("%s encountered:\n%s\nWhich is not a struct.", matchername, format.Object(actual, 1))
|
||||
}
|
||||
|
||||
var extractedValue reflect.Value
|
||||
|
||||
if strings.HasSuffix(fields[0], "()") {
|
||||
extractedValue = actualValue.MethodByName(strings.TrimSuffix(fields[0], "()"))
|
||||
if extractedValue == (reflect.Value{}) && actualValue.CanAddr() {
|
||||
extractedValue = actualValue.Addr().MethodByName(strings.TrimSuffix(fields[0], "()"))
|
||||
}
|
||||
if extractedValue == (reflect.Value{}) {
|
||||
return nil, fmt.Errorf("HaveField could not find method named '%s' in struct of type %T.", fields[0], actual)
|
||||
return nil, missingFieldError(fmt.Sprintf("%s could not find method named '%s' in struct of type %T.", matchername, fields[0], actual))
|
||||
}
|
||||
t := extractedValue.Type()
|
||||
if t.NumIn() != 0 || t.NumOut() != 1 {
|
||||
return nil, fmt.Errorf("HaveField found an invalid method named '%s' in struct of type %T.\nMethods must take no arguments and return exactly one value.", fields[0], actual)
|
||||
return nil, fmt.Errorf("%s found an invalid method named '%s' in struct of type %T.\nMethods must take no arguments and return exactly one value.", matchername, fields[0], actual)
|
||||
}
|
||||
extractedValue = extractedValue.Call([]reflect.Value{})[0]
|
||||
} else {
|
||||
extractedValue = actualValue.FieldByName(fields[0])
|
||||
if extractedValue == (reflect.Value{}) {
|
||||
return nil, fmt.Errorf("HaveField could not find field named '%s' in struct:\n%s", fields[0], format.Object(actual, 1))
|
||||
return nil, missingFieldError(fmt.Sprintf("%s could not find field named '%s' in struct:\n%s", matchername, fields[0], format.Object(actual, 1)))
|
||||
}
|
||||
}
|
||||
|
||||
if len(fields) == 1 {
|
||||
return extractedValue.Interface(), nil
|
||||
} else {
|
||||
return extractField(extractedValue.Interface(), fields[1])
|
||||
return extractField(extractedValue.Interface(), fields[1], matchername)
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,7 +70,7 @@ type HaveFieldMatcher struct {
|
||||
}
|
||||
|
||||
func (matcher *HaveFieldMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
matcher.extractedField, err = extractField(actual, matcher.Field)
|
||||
matcher.extractedField, err = extractField(actual, matcher.Field, "HaveField")
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
2
vendor/github.com/onsi/gomega/matchers/match_yaml_matcher.go
generated
vendored
2
vendor/github.com/onsi/gomega/matchers/match_yaml_matcher.go
generated
vendored
@ -5,7 +5,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/onsi/gomega/format"
|
||||
"gopkg.in/yaml.v2"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type MatchYAMLMatcher struct {
|
||||
|
Reference in New Issue
Block a user