mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
rebase: update packages in go.mod to latest releases
updated few packages in go.mod to latest available release. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
0f44c6acb7
commit
fb7dc13dfe
22
vendor/github.com/onsi/gomega/matchers/be_element_of_matcher.go
generated
vendored
22
vendor/github.com/onsi/gomega/matchers/be_element_of_matcher.go
generated
vendored
@ -18,23 +18,9 @@ func (matcher *BeElementOfMatcher) Match(actual interface{}) (success bool, err
|
||||
return false, fmt.Errorf("BeElement matcher expects actual to be typed")
|
||||
}
|
||||
|
||||
length := len(matcher.Elements)
|
||||
valueAt := func(i int) interface{} {
|
||||
return matcher.Elements[i]
|
||||
}
|
||||
// Special handling of a single element of type Array or Slice
|
||||
if length == 1 && isArrayOrSlice(valueAt(0)) {
|
||||
element := valueAt(0)
|
||||
value := reflect.ValueOf(element)
|
||||
length = value.Len()
|
||||
valueAt = func(i int) interface{} {
|
||||
return value.Index(i).Interface()
|
||||
}
|
||||
}
|
||||
|
||||
var lastError error
|
||||
for i := 0; i < length; i++ {
|
||||
matcher := &EqualMatcher{Expected: valueAt(i)}
|
||||
for _, m := range flatten(matcher.Elements) {
|
||||
matcher := &EqualMatcher{Expected: m}
|
||||
success, err := matcher.Match(actual)
|
||||
if err != nil {
|
||||
lastError = err
|
||||
@ -49,9 +35,9 @@ func (matcher *BeElementOfMatcher) Match(actual interface{}) (success bool, err
|
||||
}
|
||||
|
||||
func (matcher *BeElementOfMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "to be an element of", matcher.Elements)
|
||||
return format.Message(actual, "to be an element of", presentable(matcher.Elements))
|
||||
}
|
||||
|
||||
func (matcher *BeElementOfMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "not to be an element of", matcher.Elements)
|
||||
return format.Message(actual, "not to be an element of", presentable(matcher.Elements))
|
||||
}
|
||||
|
2
vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go
generated
vendored
2
vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go
generated
vendored
@ -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 {
|
||||
|
53
vendor/github.com/onsi/gomega/matchers/consist_of.go
generated
vendored
53
vendor/github.com/onsi/gomega/matchers/consist_of.go
generated
vendored
@ -57,17 +57,21 @@ func equalMatchersToElements(matchers []interface{}) (elements []interface{}) {
|
||||
return
|
||||
}
|
||||
|
||||
func matchers(expectedElems []interface{}) (matchers []interface{}) {
|
||||
elems := expectedElems
|
||||
if len(expectedElems) == 1 && isArrayOrSlice(expectedElems[0]) {
|
||||
elems = []interface{}{}
|
||||
value := reflect.ValueOf(expectedElems[0])
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
elems = append(elems, value.Index(i).Interface())
|
||||
}
|
||||
func flatten(elems []interface{}) []interface{} {
|
||||
if len(elems) != 1 || !isArrayOrSlice(elems[0]) {
|
||||
return elems
|
||||
}
|
||||
|
||||
for _, e := range elems {
|
||||
value := reflect.ValueOf(elems[0])
|
||||
flattened := make([]interface{}, value.Len())
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
flattened[i] = value.Index(i).Interface()
|
||||
}
|
||||
return flattened
|
||||
}
|
||||
|
||||
func matchers(expectedElems []interface{}) (matchers []interface{}) {
|
||||
for _, e := range flatten(expectedElems) {
|
||||
matcher, isMatcher := e.(omegaMatcher)
|
||||
if !isMatcher {
|
||||
matcher = &EqualMatcher{Expected: e}
|
||||
@ -77,6 +81,29 @@ func matchers(expectedElems []interface{}) (matchers []interface{}) {
|
||||
return
|
||||
}
|
||||
|
||||
func presentable(elems []interface{}) interface{} {
|
||||
elems = flatten(elems)
|
||||
|
||||
if len(elems) == 0 {
|
||||
return []interface{}{}
|
||||
}
|
||||
|
||||
sv := reflect.ValueOf(elems)
|
||||
tt := sv.Index(0).Elem().Type()
|
||||
for i := 1; i < sv.Len(); i++ {
|
||||
if sv.Index(i).Elem().Type() != tt {
|
||||
return elems
|
||||
}
|
||||
}
|
||||
|
||||
ss := reflect.MakeSlice(reflect.SliceOf(tt), sv.Len(), sv.Len())
|
||||
for i := 0; i < sv.Len(); i++ {
|
||||
ss.Index(i).Set(sv.Index(i).Elem())
|
||||
}
|
||||
|
||||
return ss.Interface()
|
||||
}
|
||||
|
||||
func valuesOf(actual interface{}) []interface{} {
|
||||
value := reflect.ValueOf(actual)
|
||||
values := []interface{}{}
|
||||
@ -95,11 +122,11 @@ func valuesOf(actual interface{}) []interface{} {
|
||||
}
|
||||
|
||||
func (matcher *ConsistOfMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
message = format.Message(actual, "to consist of", matcher.Elements)
|
||||
message = format.Message(actual, "to consist of", presentable(matcher.Elements))
|
||||
message = appendMissingElements(message, matcher.missingElements)
|
||||
if len(matcher.extraElements) > 0 {
|
||||
message = fmt.Sprintf("%s\nthe extra elements were\n%s", message,
|
||||
format.Object(matcher.extraElements, 1))
|
||||
format.Object(presentable(matcher.extraElements), 1))
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -109,9 +136,9 @@ func appendMissingElements(message string, missingElements []interface{}) string
|
||||
return message
|
||||
}
|
||||
return fmt.Sprintf("%s\nthe missing elements were\n%s", message,
|
||||
format.Object(missingElements, 1))
|
||||
format.Object(presentable(missingElements), 1))
|
||||
}
|
||||
|
||||
func (matcher *ConsistOfMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "not to consist of", matcher.Elements)
|
||||
return format.Message(actual, "not to consist of", presentable(matcher.Elements))
|
||||
}
|
||||
|
4
vendor/github.com/onsi/gomega/matchers/contain_elements_matcher.go
generated
vendored
4
vendor/github.com/onsi/gomega/matchers/contain_elements_matcher.go
generated
vendored
@ -35,10 +35,10 @@ func (matcher *ContainElementsMatcher) Match(actual interface{}) (success bool,
|
||||
}
|
||||
|
||||
func (matcher *ContainElementsMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
message = format.Message(actual, "to contain elements", matcher.Elements)
|
||||
message = format.Message(actual, "to contain elements", presentable(matcher.Elements))
|
||||
return appendMissingElements(message, matcher.missingElements)
|
||||
}
|
||||
|
||||
func (matcher *ContainElementsMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "not to contain elements", matcher.Elements)
|
||||
return format.Message(actual, "not to contain elements", presentable(matcher.Elements))
|
||||
}
|
||||
|
42
vendor/github.com/onsi/gomega/matchers/have_http_status_matcher.go
generated
vendored
Normal file
42
vendor/github.com/onsi/gomega/matchers/have_http_status_matcher.go
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
package matchers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
||||
"github.com/onsi/gomega/format"
|
||||
)
|
||||
|
||||
type HaveHTTPStatusMatcher struct {
|
||||
Expected interface{}
|
||||
}
|
||||
|
||||
func (matcher *HaveHTTPStatusMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
var resp *http.Response
|
||||
switch a := actual.(type) {
|
||||
case *http.Response:
|
||||
resp = a
|
||||
case *httptest.ResponseRecorder:
|
||||
resp = a.Result()
|
||||
default:
|
||||
return false, fmt.Errorf("HaveHTTPStatus matcher expects *http.Response or *httptest.ResponseRecorder. Got:\n%s", format.Object(actual, 1))
|
||||
}
|
||||
|
||||
switch e := matcher.Expected.(type) {
|
||||
case int:
|
||||
return resp.StatusCode == e, nil
|
||||
case string:
|
||||
return resp.Status == e, nil
|
||||
}
|
||||
|
||||
return false, fmt.Errorf("HaveHTTPStatus matcher must be passed an int or a string. Got:\n%s", format.Object(matcher.Expected, 1))
|
||||
}
|
||||
|
||||
func (matcher *HaveHTTPStatusMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "to have HTTP status", matcher.Expected)
|
||||
}
|
||||
|
||||
func (matcher *HaveHTTPStatusMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "not to have HTTP status", matcher.Expected)
|
||||
}
|
4
vendor/github.com/onsi/gomega/matchers/match_error_matcher.go
generated
vendored
4
vendor/github.com/onsi/gomega/matchers/match_error_matcher.go
generated
vendored
@ -1,11 +1,11 @@
|
||||
package matchers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/onsi/gomega/format"
|
||||
"golang.org/x/xerrors"
|
||||
)
|
||||
|
||||
type MatchErrorMatcher struct {
|
||||
@ -25,7 +25,7 @@ func (matcher *MatchErrorMatcher) Match(actual interface{}) (success bool, err e
|
||||
expected := matcher.Expected
|
||||
|
||||
if isError(expected) {
|
||||
return reflect.DeepEqual(actualErr, expected) || xerrors.Is(actualErr, expected.(error)), nil
|
||||
return reflect.DeepEqual(actualErr, expected) || errors.Is(actualErr, expected.(error)), nil
|
||||
}
|
||||
|
||||
if isString(expected) {
|
||||
|
76
vendor/github.com/onsi/gomega/matchers/panic_matcher.go
generated
vendored
76
vendor/github.com/onsi/gomega/matchers/panic_matcher.go
generated
vendored
@ -8,7 +8,8 @@ import (
|
||||
)
|
||||
|
||||
type PanicMatcher struct {
|
||||
object interface{}
|
||||
Expected interface{}
|
||||
object interface{}
|
||||
}
|
||||
|
||||
func (matcher *PanicMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
@ -28,7 +29,21 @@ func (matcher *PanicMatcher) Match(actual interface{}) (success bool, err error)
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
matcher.object = e
|
||||
success = true
|
||||
|
||||
if matcher.Expected == nil {
|
||||
success = true
|
||||
return
|
||||
}
|
||||
|
||||
valueMatcher, valueIsMatcher := matcher.Expected.(omegaMatcher)
|
||||
if !valueIsMatcher {
|
||||
valueMatcher = &EqualMatcher{Expected: matcher.Expected}
|
||||
}
|
||||
|
||||
success, err = valueMatcher.Match(e)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("PanicMatcher's value matcher failed with:\n%s%s", format.Indent, err.Error())
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
@ -38,9 +53,62 @@ func (matcher *PanicMatcher) Match(actual interface{}) (success bool, err error)
|
||||
}
|
||||
|
||||
func (matcher *PanicMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "to panic")
|
||||
if matcher.Expected == nil {
|
||||
// We wanted any panic to occur, but none did.
|
||||
return format.Message(actual, "to panic")
|
||||
}
|
||||
|
||||
if matcher.object == nil {
|
||||
// We wanted a panic with a specific value to occur, but none did.
|
||||
switch matcher.Expected.(type) {
|
||||
case omegaMatcher:
|
||||
return format.Message(actual, "to panic with a value matching", matcher.Expected)
|
||||
default:
|
||||
return format.Message(actual, "to panic with", matcher.Expected)
|
||||
}
|
||||
}
|
||||
|
||||
// We got a panic, but the value isn't what we expected.
|
||||
switch matcher.Expected.(type) {
|
||||
case omegaMatcher:
|
||||
return format.Message(
|
||||
actual,
|
||||
fmt.Sprintf(
|
||||
"to panic with a value matching\n%s\nbut panicked with\n%s",
|
||||
format.Object(matcher.Expected, 1),
|
||||
format.Object(matcher.object, 1),
|
||||
),
|
||||
)
|
||||
default:
|
||||
return format.Message(
|
||||
actual,
|
||||
fmt.Sprintf(
|
||||
"to panic with\n%s\nbut panicked with\n%s",
|
||||
format.Object(matcher.Expected, 1),
|
||||
format.Object(matcher.object, 1),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func (matcher *PanicMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, fmt.Sprintf("not to panic, but panicked with\n%s", format.Object(matcher.object, 1)))
|
||||
if matcher.Expected == nil {
|
||||
// We didn't want any panic to occur, but one did.
|
||||
return format.Message(actual, fmt.Sprintf("not to panic, but panicked with\n%s", format.Object(matcher.object, 1)))
|
||||
}
|
||||
|
||||
// We wanted a to ensure a panic with a specific value did not occur, but it did.
|
||||
switch matcher.Expected.(type) {
|
||||
case omegaMatcher:
|
||||
return format.Message(
|
||||
actual,
|
||||
fmt.Sprintf(
|
||||
"not to panic with a value matching\n%s\nbut panicked with\n%s",
|
||||
format.Object(matcher.Expected, 1),
|
||||
format.Object(matcher.object, 1),
|
||||
),
|
||||
)
|
||||
default:
|
||||
return format.Message(actual, "not to panic with", matcher.Expected)
|
||||
}
|
||||
}
|
||||
|
66
vendor/github.com/onsi/gomega/matchers/satisfy_matcher.go
generated
vendored
Normal file
66
vendor/github.com/onsi/gomega/matchers/satisfy_matcher.go
generated
vendored
Normal file
@ -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)
|
||||
}
|
19
vendor/github.com/onsi/gomega/matchers/with_transform.go
generated
vendored
19
vendor/github.com/onsi/gomega/matchers/with_transform.go
generated
vendored
@ -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)
|
||||
|
Reference in New Issue
Block a user