rebase: bump github.com/onsi/gomega from 1.20.1 to 1.22.1

Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.20.1 to 1.22.1.
- [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.20.1...v1.22.1)

---
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:
dependabot[bot] 2022-10-20 09:06:44 +00:00 committed by mergify[bot]
parent 02ed5ec189
commit 49245788fc
7 changed files with 76 additions and 23 deletions

2
go.mod
View File

@ -23,7 +23,7 @@ require (
github.com/kubernetes-csi/external-snapshotter/client/v6 v6.0.1 github.com/kubernetes-csi/external-snapshotter/client/v6 v6.0.1
github.com/libopenstorage/secrets v0.0.0-20210908194121-a1d19aa9713a github.com/libopenstorage/secrets v0.0.0-20210908194121-a1d19aa9713a
github.com/onsi/ginkgo/v2 v2.3.1 github.com/onsi/ginkgo/v2 v2.3.1
github.com/onsi/gomega v1.22.0 github.com/onsi/gomega v1.22.1
github.com/pkg/xattr v0.4.7 github.com/pkg/xattr v0.4.7
github.com/prometheus/client_golang v1.12.2 github.com/prometheus/client_golang v1.12.2
github.com/stretchr/testify v1.8.0 github.com/stretchr/testify v1.8.0

5
go.sum
View File

@ -940,6 +940,7 @@ github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042
github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU=
github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk=
github.com/onsi/ginkgo/v2 v2.3.0/go.mod h1:Eew0uilEqZmIEZr8JrvYlvOM7Rr6xzTmMV8AyFNU9d0=
github.com/onsi/ginkgo/v2 v2.3.1 h1:8SbseP7qM32WcvE6VaN6vfXxv698izmsJ1UQX9ve7T8= github.com/onsi/ginkgo/v2 v2.3.1 h1:8SbseP7qM32WcvE6VaN6vfXxv698izmsJ1UQX9ve7T8=
github.com/onsi/ginkgo/v2 v2.3.1/go.mod h1:Sv4yQXwG5VmF7tm3Q5Z+RWUpPo24LF1mpnz2crUb8Ys= github.com/onsi/ginkgo/v2 v2.3.1/go.mod h1:Sv4yQXwG5VmF7tm3Q5Z+RWUpPo24LF1mpnz2crUb8Ys=
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
@ -951,8 +952,10 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo=
github.com/onsi/gomega v1.22.0 h1:AIg2/OntwkBiCg5Tt1ayyiF1ArFrWFoCSMtMi/wdApk= github.com/onsi/gomega v1.21.1/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc=
github.com/onsi/gomega v1.22.0/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc= github.com/onsi/gomega v1.22.0/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc=
github.com/onsi/gomega v1.22.1 h1:pY8O4lBfsHKZHM/6nrxkhVPUznOlIu3quZcKP/M20KI=
github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM=
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=

View File

@ -1,3 +1,12 @@
## 1.22.1
## Fixes
- When passed a context and no explicit timeout, Eventually will only timeout when the context is cancelled [e5105cf]
- Allow StopTrying() to be wrapped [bf3cba9]
## Maintenance
- bump to ginkgo v2.3.0 [c5d5c39]
## 1.22.0 ## 1.22.0
### Features ### Features

View File

@ -22,7 +22,7 @@ import (
"github.com/onsi/gomega/types" "github.com/onsi/gomega/types"
) )
const GOMEGA_VERSION = "1.22.0" const GOMEGA_VERSION = "1.22.1"
const nilGomegaPanic = `You are trying to make an assertion, but haven't registered Gomega's fail handler. 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(). If you're using Ginkgo then you probably forgot to put your assertion in an It().

View File

@ -2,6 +2,7 @@ package internal
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"reflect" "reflect"
"runtime" "runtime"
@ -17,6 +18,22 @@ type StopTryingError interface {
wasViaPanic() bool wasViaPanic() bool
} }
func asStopTryingError(actual interface{}) (StopTryingError, bool) {
if actual == nil {
return nil, false
}
if actualErr, ok := actual.(error); ok {
var target *stopTryingError
if errors.As(actualErr, &target) {
return target, true
} else {
return nil, false
}
}
return nil, false
}
type stopTryingError struct { type stopTryingError struct {
message string message string
viaPanic bool viaPanic bool
@ -35,8 +52,6 @@ func (s *stopTryingError) wasViaPanic() bool {
return s.viaPanic return s.viaPanic
} }
var stopTryingErrorType = reflect.TypeOf(&stopTryingError{})
var StopTrying = func(message string) StopTryingError { var StopTrying = func(message string) StopTryingError {
return &stopTryingError{message: message} return &stopTryingError{message: message}
} }
@ -157,20 +172,19 @@ func (assertion *AsyncAssertion) processReturnValues(values []reflect.Value) (in
return nil, fmt.Errorf("No values were returned by the function passed to Gomega"), stopTrying return nil, fmt.Errorf("No values were returned by the function passed to Gomega"), stopTrying
} }
actual := values[0].Interface() actual := values[0].Interface()
if actual != nil && reflect.TypeOf(actual) == stopTryingErrorType { if stopTryingErr, ok := asStopTryingError(actual); ok {
stopTrying = actual.(StopTryingError) stopTrying = stopTryingErr
} }
for i, extraValue := range values[1:] { for i, extraValue := range values[1:] {
extra := extraValue.Interface() extra := extraValue.Interface()
if extra == nil { if extra == nil {
continue continue
} }
extraType := reflect.TypeOf(extra) if stopTryingErr, ok := asStopTryingError(extra); ok {
if extraType == stopTryingErrorType { stopTrying = stopTryingErr
stopTrying = extra.(StopTryingError)
continue continue
} }
zero := reflect.Zero(extraType).Interface() zero := reflect.Zero(reflect.TypeOf(extra)).Interface()
if reflect.DeepEqual(extra, zero) { if reflect.DeepEqual(extra, zero) {
continue continue
} }
@ -226,8 +240,8 @@ func (assertion *AsyncAssertion) buildActualPoller() (func() (interface{}, error
return func() (actual interface{}, err error, stopTrying StopTryingError) { return func() (actual interface{}, err error, stopTrying StopTryingError) {
defer func() { defer func() {
if e := recover(); e != nil { if e := recover(); e != nil {
if reflect.TypeOf(e) == stopTryingErrorType { if stopTryingErr, ok := asStopTryingError(e); ok {
stopTrying = e.(StopTryingError) stopTrying = stopTryingErr
} else { } else {
panic(e) panic(e)
} }
@ -291,8 +305,8 @@ func (assertion *AsyncAssertion) buildActualPoller() (func() (interface{}, error
} }
} }
if e := recover(); e != nil { if e := recover(); e != nil {
if reflect.TypeOf(e) == stopTryingErrorType { if stopTryingErr, ok := asStopTryingError(e); ok {
stopTrying = e.(StopTryingError) stopTrying = stopTryingErr
} else if assertionFailure == nil { } else if assertionFailure == nil {
panic(e) panic(e)
} }
@ -310,13 +324,40 @@ func (assertion *AsyncAssertion) matcherSaysStopTrying(matcher types.GomegaMatch
return StopTrying("No future change is possible. Bailing out early") return StopTrying("No future change is possible. Bailing out early")
} }
func (assertion *AsyncAssertion) afterTimeout() <-chan time.Time {
if assertion.timeoutInterval >= 0 {
return time.After(assertion.timeoutInterval)
}
if assertion.asyncType == AsyncAssertionTypeConsistently {
return time.After(assertion.g.DurationBundle.ConsistentlyDuration)
} else {
if assertion.ctx == nil {
return time.After(assertion.g.DurationBundle.EventuallyTimeout)
} else {
return nil
}
}
}
func (assertion *AsyncAssertion) afterPolling() <-chan time.Time {
if assertion.pollingInterval >= 0 {
return time.After(assertion.pollingInterval)
}
if assertion.asyncType == AsyncAssertionTypeConsistently {
return time.After(assertion.g.DurationBundle.ConsistentlyPollingInterval)
} else {
return time.After(assertion.g.DurationBundle.EventuallyPollingInterval)
}
}
type contextWithAttachProgressReporter interface { type contextWithAttachProgressReporter interface {
AttachProgressReporter(func() string) func() AttachProgressReporter(func() string) func()
} }
func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch bool, optionalDescription ...interface{}) bool { func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch bool, optionalDescription ...interface{}) bool {
timer := time.Now() timer := time.Now()
timeout := time.After(assertion.timeoutInterval) timeout := assertion.afterTimeout()
lock := sync.Mutex{} lock := sync.Mutex{}
var matches bool var matches bool
@ -383,7 +424,7 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
} }
select { select {
case <-time.After(assertion.pollingInterval): case <-assertion.afterPolling():
v, e, st := pollActual() v, e, st := pollActual()
if st != nil && st.wasViaPanic() { if st != nil && st.wasViaPanic() {
// we were told to stop trying via panic - which means we dont' have reasonable new values // we were told to stop trying via panic - which means we dont' have reasonable new values
@ -423,7 +464,7 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
} }
select { select {
case <-time.After(assertion.pollingInterval): case <-assertion.afterPolling():
v, e, st := pollActual() v, e, st := pollActual()
if st != nil && st.wasViaPanic() { if st != nil && st.wasViaPanic() {
// we were told to stop trying via panic - which means we made it this far and should return successfully // we were told to stop trying via panic - which means we made it this far and should return successfully

View File

@ -57,8 +57,8 @@ func (g *Gomega) Eventually(actual interface{}, intervals ...interface{}) types.
} }
func (g *Gomega) EventuallyWithOffset(offset int, actual interface{}, args ...interface{}) types.AsyncAssertion { func (g *Gomega) EventuallyWithOffset(offset int, actual interface{}, args ...interface{}) types.AsyncAssertion {
timeoutInterval := g.DurationBundle.EventuallyTimeout timeoutInterval := -time.Duration(1)
pollingInterval := g.DurationBundle.EventuallyPollingInterval pollingInterval := -time.Duration(1)
intervals := []interface{}{} intervals := []interface{}{}
var ctx context.Context var ctx context.Context
for _, arg := range args { for _, arg := range args {
@ -84,8 +84,8 @@ func (g *Gomega) Consistently(actual interface{}, intervals ...interface{}) type
} }
func (g *Gomega) ConsistentlyWithOffset(offset int, actual interface{}, args ...interface{}) types.AsyncAssertion { func (g *Gomega) ConsistentlyWithOffset(offset int, actual interface{}, args ...interface{}) types.AsyncAssertion {
timeoutInterval := g.DurationBundle.ConsistentlyDuration timeoutInterval := -time.Duration(1)
pollingInterval := g.DurationBundle.ConsistentlyPollingInterval pollingInterval := -time.Duration(1)
intervals := []interface{}{} intervals := []interface{}{}
var ctx context.Context var ctx context.Context
for _, arg := range args { for _, arg := range args {

2
vendor/modules.txt vendored
View File

@ -454,7 +454,7 @@ github.com/onsi/ginkgo/v2/internal/parallel_support
github.com/onsi/ginkgo/v2/internal/testingtproxy github.com/onsi/ginkgo/v2/internal/testingtproxy
github.com/onsi/ginkgo/v2/reporters github.com/onsi/ginkgo/v2/reporters
github.com/onsi/ginkgo/v2/types github.com/onsi/ginkgo/v2/types
# github.com/onsi/gomega v1.22.0 # github.com/onsi/gomega v1.22.1
## explicit; go 1.18 ## explicit; go 1.18
github.com/onsi/gomega github.com/onsi/gomega
github.com/onsi/gomega/format github.com/onsi/gomega/format