mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rebase: bump github.com/onsi/ginkgo/v2 from 2.1.6 to 2.3.1
Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.1.6 to 2.3.1. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.1.6...v2.3.1) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 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
53bb28e0d9
commit
3a490a4df0
389
vendor/github.com/onsi/gomega/internal/async_assertion.go
generated
vendored
389
vendor/github.com/onsi/gomega/internal/async_assertion.go
generated
vendored
@ -1,15 +1,46 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/gomega/types"
|
||||
)
|
||||
|
||||
type StopTryingError interface {
|
||||
error
|
||||
Now()
|
||||
wasViaPanic() bool
|
||||
}
|
||||
|
||||
type stopTryingError struct {
|
||||
message string
|
||||
viaPanic bool
|
||||
}
|
||||
|
||||
func (s *stopTryingError) Error() string {
|
||||
return s.message
|
||||
}
|
||||
|
||||
func (s *stopTryingError) Now() {
|
||||
s.viaPanic = true
|
||||
panic(s)
|
||||
}
|
||||
|
||||
func (s *stopTryingError) wasViaPanic() bool {
|
||||
return s.viaPanic
|
||||
}
|
||||
|
||||
var stopTryingErrorType = reflect.TypeOf(&stopTryingError{})
|
||||
|
||||
var StopTrying = func(message string) StopTryingError {
|
||||
return &stopTryingError{message: message}
|
||||
}
|
||||
|
||||
type AsyncAssertionType uint
|
||||
|
||||
const (
|
||||
@ -17,71 +48,43 @@ const (
|
||||
AsyncAssertionTypeConsistently
|
||||
)
|
||||
|
||||
func (at AsyncAssertionType) String() string {
|
||||
switch at {
|
||||
case AsyncAssertionTypeEventually:
|
||||
return "Eventually"
|
||||
case AsyncAssertionTypeConsistently:
|
||||
return "Consistently"
|
||||
}
|
||||
return "INVALID ASYNC ASSERTION TYPE"
|
||||
}
|
||||
|
||||
type AsyncAssertion struct {
|
||||
asyncType AsyncAssertionType
|
||||
|
||||
actualIsFunc bool
|
||||
actualValue interface{}
|
||||
actualFunc func() ([]reflect.Value, error)
|
||||
actualIsFunc bool
|
||||
actual interface{}
|
||||
argsToForward []interface{}
|
||||
|
||||
timeoutInterval time.Duration
|
||||
pollingInterval time.Duration
|
||||
ctx context.Context
|
||||
offset int
|
||||
g *Gomega
|
||||
}
|
||||
|
||||
func NewAsyncAssertion(asyncType AsyncAssertionType, actualInput interface{}, g *Gomega, timeoutInterval time.Duration, pollingInterval time.Duration, offset int) *AsyncAssertion {
|
||||
func NewAsyncAssertion(asyncType AsyncAssertionType, actualInput interface{}, g *Gomega, timeoutInterval time.Duration, pollingInterval time.Duration, ctx context.Context, offset int) *AsyncAssertion {
|
||||
out := &AsyncAssertion{
|
||||
asyncType: asyncType,
|
||||
timeoutInterval: timeoutInterval,
|
||||
pollingInterval: pollingInterval,
|
||||
offset: offset,
|
||||
ctx: ctx,
|
||||
g: g,
|
||||
}
|
||||
|
||||
switch actualType := reflect.TypeOf(actualInput); {
|
||||
case actualInput == nil || actualType.Kind() != reflect.Func:
|
||||
out.actualValue = actualInput
|
||||
case actualType.NumIn() == 0 && actualType.NumOut() > 0:
|
||||
out.actual = actualInput
|
||||
if actualInput != nil && reflect.TypeOf(actualInput).Kind() == reflect.Func {
|
||||
out.actualIsFunc = true
|
||||
out.actualFunc = func() ([]reflect.Value, error) {
|
||||
return reflect.ValueOf(actualInput).Call([]reflect.Value{}), nil
|
||||
}
|
||||
case actualType.NumIn() == 1 && actualType.In(0).Implements(reflect.TypeOf((*types.Gomega)(nil)).Elem()):
|
||||
out.actualIsFunc = true
|
||||
out.actualFunc = func() (values []reflect.Value, err error) {
|
||||
var assertionFailure error
|
||||
assertionCapturingGomega := NewGomega(g.DurationBundle).ConfigureWithFailHandler(func(message string, callerSkip ...int) {
|
||||
skip := 0
|
||||
if len(callerSkip) > 0 {
|
||||
skip = callerSkip[0]
|
||||
}
|
||||
_, file, line, _ := runtime.Caller(skip + 1)
|
||||
assertionFailure = fmt.Errorf("Assertion in callback at %s:%d failed:\n%s", file, line, message)
|
||||
panic("stop execution")
|
||||
})
|
||||
|
||||
defer func() {
|
||||
if actualType.NumOut() == 0 {
|
||||
if assertionFailure == nil {
|
||||
values = []reflect.Value{reflect.Zero(reflect.TypeOf((*error)(nil)).Elem())}
|
||||
} else {
|
||||
values = []reflect.Value{reflect.ValueOf(assertionFailure)}
|
||||
}
|
||||
} else {
|
||||
err = assertionFailure
|
||||
}
|
||||
if e := recover(); e != nil && assertionFailure == nil {
|
||||
panic(e)
|
||||
}
|
||||
}()
|
||||
|
||||
values = reflect.ValueOf(actualInput).Call([]reflect.Value{reflect.ValueOf(assertionCapturingGomega)})
|
||||
return
|
||||
}
|
||||
default:
|
||||
msg := fmt.Sprintf("The function passed to Gomega's async assertions should either take no arguments and return values, or take a single Gomega interface that it can use to make assertions within the body of the function. When taking a Gomega interface the function can optionally return values or return nothing. The function you passed takes %d arguments and returns %d values.", actualType.NumIn(), actualType.NumOut())
|
||||
g.Fail(msg, offset+4)
|
||||
}
|
||||
|
||||
return out
|
||||
@ -102,6 +105,26 @@ func (assertion *AsyncAssertion) WithPolling(interval time.Duration) types.Async
|
||||
return assertion
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) Within(timeout time.Duration) types.AsyncAssertion {
|
||||
assertion.timeoutInterval = timeout
|
||||
return assertion
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) ProbeEvery(interval time.Duration) types.AsyncAssertion {
|
||||
assertion.pollingInterval = interval
|
||||
return assertion
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) WithContext(ctx context.Context) types.AsyncAssertion {
|
||||
assertion.ctx = ctx
|
||||
return assertion
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) WithArguments(argsToForward ...interface{}) types.AsyncAssertion {
|
||||
assertion.argsToForward = argsToForward
|
||||
return assertion
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
|
||||
assertion.g.THelper()
|
||||
vetOptionalDescription("Asynchronous assertion", optionalDescription...)
|
||||
@ -126,50 +149,199 @@ func (assertion *AsyncAssertion) buildDescription(optionalDescription ...interfa
|
||||
return fmt.Sprintf(optionalDescription[0].(string), optionalDescription[1:]...) + "\n"
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) pollActual() (interface{}, error) {
|
||||
if !assertion.actualIsFunc {
|
||||
return assertion.actualValue, nil
|
||||
}
|
||||
func (assertion *AsyncAssertion) processReturnValues(values []reflect.Value) (interface{}, error, StopTryingError) {
|
||||
var err error
|
||||
var stopTrying StopTryingError
|
||||
|
||||
values, err := assertion.actualFunc()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if len(values) == 0 {
|
||||
return nil, fmt.Errorf("No values were returned by the function passed to Gomega"), stopTrying
|
||||
}
|
||||
extras := []interface{}{nil}
|
||||
for _, value := range values[1:] {
|
||||
extras = append(extras, value.Interface())
|
||||
actual := values[0].Interface()
|
||||
if actual != nil && reflect.TypeOf(actual) == stopTryingErrorType {
|
||||
stopTrying = actual.(StopTryingError)
|
||||
}
|
||||
success, message := vetActuals(extras, 0)
|
||||
if !success {
|
||||
return nil, errors.New(message)
|
||||
for i, extraValue := range values[1:] {
|
||||
extra := extraValue.Interface()
|
||||
if extra == nil {
|
||||
continue
|
||||
}
|
||||
extraType := reflect.TypeOf(extra)
|
||||
if extraType == stopTryingErrorType {
|
||||
stopTrying = extra.(StopTryingError)
|
||||
continue
|
||||
}
|
||||
zero := reflect.Zero(extraType).Interface()
|
||||
if reflect.DeepEqual(extra, zero) {
|
||||
continue
|
||||
}
|
||||
if err == nil {
|
||||
err = fmt.Errorf("Unexpected non-nil/non-zero argument at index %d:\n\t<%T>: %#v", i+1, extra, extra)
|
||||
}
|
||||
}
|
||||
|
||||
return values[0].Interface(), nil
|
||||
return actual, err, stopTrying
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) matcherMayChange(matcher types.GomegaMatcher, value interface{}) bool {
|
||||
if assertion.actualIsFunc {
|
||||
return true
|
||||
var gomegaType = reflect.TypeOf((*types.Gomega)(nil)).Elem()
|
||||
var contextType = reflect.TypeOf(new(context.Context)).Elem()
|
||||
|
||||
func (assertion *AsyncAssertion) invalidFunctionError(t reflect.Type) error {
|
||||
return fmt.Errorf(`The function passed to %s had an invalid signature of %s. Functions passed to %s must either:
|
||||
|
||||
(a) have return values or
|
||||
(b) take a Gomega interface as their first argument and use that Gomega instance to make assertions.
|
||||
|
||||
You can learn more at https://onsi.github.io/gomega/#eventually
|
||||
`, assertion.asyncType, t, assertion.asyncType)
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) noConfiguredContextForFunctionError() error {
|
||||
return fmt.Errorf(`The function passed to %s requested a context.Context, but no context has been provided. Please pass one in using %s().WithContext().
|
||||
|
||||
You can learn more at https://onsi.github.io/gomega/#eventually
|
||||
`, assertion.asyncType, assertion.asyncType)
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) argumentMismatchError(t reflect.Type, numProvided int) error {
|
||||
have := "have"
|
||||
if numProvided == 1 {
|
||||
have = "has"
|
||||
}
|
||||
return types.MatchMayChangeInTheFuture(matcher, value)
|
||||
return fmt.Errorf(`The function passed to %s has signature %s takes %d arguments but %d %s been provided. Please use %s().WithArguments() to pass the corect set of arguments.
|
||||
|
||||
You can learn more at https://onsi.github.io/gomega/#eventually
|
||||
`, assertion.asyncType, t, t.NumIn(), numProvided, have, assertion.asyncType)
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) buildActualPoller() (func() (interface{}, error, StopTryingError), error) {
|
||||
if !assertion.actualIsFunc {
|
||||
return func() (interface{}, error, StopTryingError) { return assertion.actual, nil, nil }, nil
|
||||
}
|
||||
actualValue := reflect.ValueOf(assertion.actual)
|
||||
actualType := reflect.TypeOf(assertion.actual)
|
||||
numIn, numOut, isVariadic := actualType.NumIn(), actualType.NumOut(), actualType.IsVariadic()
|
||||
|
||||
if numIn == 0 && numOut == 0 {
|
||||
return nil, assertion.invalidFunctionError(actualType)
|
||||
} else if numIn == 0 {
|
||||
return func() (actual interface{}, err error, stopTrying StopTryingError) {
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
if reflect.TypeOf(e) == stopTryingErrorType {
|
||||
stopTrying = e.(StopTryingError)
|
||||
} else {
|
||||
panic(e)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
actual, err, stopTrying = assertion.processReturnValues(actualValue.Call([]reflect.Value{}))
|
||||
return
|
||||
}, nil
|
||||
}
|
||||
takesGomega, takesContext := actualType.In(0).Implements(gomegaType), actualType.In(0).Implements(contextType)
|
||||
if takesGomega && numIn > 1 && actualType.In(1).Implements(contextType) {
|
||||
takesContext = true
|
||||
}
|
||||
if takesContext && len(assertion.argsToForward) > 0 && reflect.TypeOf(assertion.argsToForward[0]).Implements(contextType) {
|
||||
takesContext = false
|
||||
}
|
||||
if !takesGomega && numOut == 0 {
|
||||
return nil, assertion.invalidFunctionError(actualType)
|
||||
}
|
||||
if takesContext && assertion.ctx == nil {
|
||||
return nil, assertion.noConfiguredContextForFunctionError()
|
||||
}
|
||||
|
||||
var assertionFailure error
|
||||
inValues := []reflect.Value{}
|
||||
if takesGomega {
|
||||
inValues = append(inValues, reflect.ValueOf(NewGomega(assertion.g.DurationBundle).ConfigureWithFailHandler(func(message string, callerSkip ...int) {
|
||||
skip := 0
|
||||
if len(callerSkip) > 0 {
|
||||
skip = callerSkip[0]
|
||||
}
|
||||
_, file, line, _ := runtime.Caller(skip + 1)
|
||||
assertionFailure = fmt.Errorf("Assertion in callback at %s:%d failed:\n%s", file, line, message)
|
||||
panic("stop execution")
|
||||
})))
|
||||
}
|
||||
if takesContext {
|
||||
inValues = append(inValues, reflect.ValueOf(assertion.ctx))
|
||||
}
|
||||
for _, arg := range assertion.argsToForward {
|
||||
inValues = append(inValues, reflect.ValueOf(arg))
|
||||
}
|
||||
|
||||
if !isVariadic && numIn != len(inValues) {
|
||||
return nil, assertion.argumentMismatchError(actualType, len(inValues))
|
||||
} else if isVariadic && len(inValues) < numIn-1 {
|
||||
return nil, assertion.argumentMismatchError(actualType, len(inValues))
|
||||
}
|
||||
|
||||
return func() (actual interface{}, err error, stopTrying StopTryingError) {
|
||||
var values []reflect.Value
|
||||
assertionFailure = nil
|
||||
defer func() {
|
||||
if numOut == 0 {
|
||||
actual = assertionFailure
|
||||
} else {
|
||||
actual, err, stopTrying = assertion.processReturnValues(values)
|
||||
if assertionFailure != nil {
|
||||
err = assertionFailure
|
||||
}
|
||||
}
|
||||
if e := recover(); e != nil {
|
||||
if reflect.TypeOf(e) == stopTryingErrorType {
|
||||
stopTrying = e.(StopTryingError)
|
||||
} else if assertionFailure == nil {
|
||||
panic(e)
|
||||
}
|
||||
}
|
||||
}()
|
||||
values = actualValue.Call(inValues)
|
||||
return
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) matcherSaysStopTrying(matcher types.GomegaMatcher, value interface{}) StopTryingError {
|
||||
if assertion.actualIsFunc || types.MatchMayChangeInTheFuture(matcher, value) {
|
||||
return nil
|
||||
}
|
||||
return StopTrying("No future change is possible. Bailing out early")
|
||||
}
|
||||
|
||||
type contextWithAttachProgressReporter interface {
|
||||
AttachProgressReporter(func() string) func()
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch bool, optionalDescription ...interface{}) bool {
|
||||
timer := time.Now()
|
||||
timeout := time.After(assertion.timeoutInterval)
|
||||
lock := sync.Mutex{}
|
||||
|
||||
var matches bool
|
||||
var err error
|
||||
mayChange := true
|
||||
value, err := assertion.pollActual()
|
||||
if err == nil {
|
||||
mayChange = assertion.matcherMayChange(matcher, value)
|
||||
matches, err = matcher.Match(value)
|
||||
}
|
||||
|
||||
assertion.g.THelper()
|
||||
|
||||
fail := func(preamble string) {
|
||||
pollActual, err := assertion.buildActualPoller()
|
||||
if err != nil {
|
||||
assertion.g.Fail(err.Error(), 2+assertion.offset)
|
||||
return false
|
||||
}
|
||||
|
||||
value, err, stopTrying := pollActual()
|
||||
if err == nil {
|
||||
if stopTrying == nil {
|
||||
stopTrying = assertion.matcherSaysStopTrying(matcher, value)
|
||||
}
|
||||
matches, err = matcher.Match(value)
|
||||
}
|
||||
|
||||
messageGenerator := func() string {
|
||||
// can be called out of band by Ginkgo if the user requests a progress report
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
errMsg := ""
|
||||
message := ""
|
||||
if err != nil {
|
||||
@ -181,9 +353,22 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||
message = matcher.NegatedFailureMessage(value)
|
||||
}
|
||||
}
|
||||
assertion.g.THelper()
|
||||
description := assertion.buildDescription(optionalDescription...)
|
||||
assertion.g.Fail(fmt.Sprintf("%s after %.3fs.\n%s%s%s", preamble, time.Since(timer).Seconds(), description, message, errMsg), 3+assertion.offset)
|
||||
return fmt.Sprintf("%s%s%s", description, message, errMsg)
|
||||
}
|
||||
|
||||
fail := func(preamble string) {
|
||||
assertion.g.THelper()
|
||||
assertion.g.Fail(fmt.Sprintf("%s after %.3fs.\n%s", preamble, time.Since(timer).Seconds(), messageGenerator()), 3+assertion.offset)
|
||||
}
|
||||
|
||||
var contextDone <-chan struct{}
|
||||
if assertion.ctx != nil {
|
||||
contextDone = assertion.ctx.Done()
|
||||
if v, ok := assertion.ctx.Value("GINKGO_SPEC_CONTEXT").(contextWithAttachProgressReporter); ok {
|
||||
detach := v.AttachProgressReporter(messageGenerator)
|
||||
defer detach()
|
||||
}
|
||||
}
|
||||
|
||||
if assertion.asyncType == AsyncAssertionTypeEventually {
|
||||
@ -192,18 +377,35 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||
return true
|
||||
}
|
||||
|
||||
if !mayChange {
|
||||
fail("No future change is possible. Bailing out early")
|
||||
if stopTrying != nil {
|
||||
fail(stopTrying.Error() + " -")
|
||||
return false
|
||||
}
|
||||
|
||||
select {
|
||||
case <-time.After(assertion.pollingInterval):
|
||||
value, err = assertion.pollActual()
|
||||
if err == nil {
|
||||
mayChange = assertion.matcherMayChange(matcher, value)
|
||||
matches, err = matcher.Match(value)
|
||||
v, e, st := pollActual()
|
||||
if st != nil && st.wasViaPanic() {
|
||||
// we were told to stop trying via panic - which means we dont' have reasonable new values
|
||||
// we should simply use the old values and exit now
|
||||
fail(st.Error() + " -")
|
||||
return false
|
||||
}
|
||||
lock.Lock()
|
||||
value, err, stopTrying = v, e, st
|
||||
lock.Unlock()
|
||||
if err == nil {
|
||||
if stopTrying == nil {
|
||||
stopTrying = assertion.matcherSaysStopTrying(matcher, value)
|
||||
}
|
||||
matches, e = matcher.Match(value)
|
||||
lock.Lock()
|
||||
err = e
|
||||
lock.Unlock()
|
||||
}
|
||||
case <-contextDone:
|
||||
fail("Context was cancelled")
|
||||
return false
|
||||
case <-timeout:
|
||||
fail("Timed out")
|
||||
return false
|
||||
@ -216,17 +418,32 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||
return false
|
||||
}
|
||||
|
||||
if !mayChange {
|
||||
if stopTrying != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
select {
|
||||
case <-time.After(assertion.pollingInterval):
|
||||
value, err = assertion.pollActual()
|
||||
if err == nil {
|
||||
mayChange = assertion.matcherMayChange(matcher, value)
|
||||
matches, err = matcher.Match(value)
|
||||
v, e, st := pollActual()
|
||||
if st != nil && st.wasViaPanic() {
|
||||
// we were told to stop trying via panic - which means we made it this far and should return successfully
|
||||
return true
|
||||
}
|
||||
lock.Lock()
|
||||
value, err, stopTrying = v, e, st
|
||||
lock.Unlock()
|
||||
if err == nil {
|
||||
if stopTrying == nil {
|
||||
stopTrying = assertion.matcherSaysStopTrying(matcher, value)
|
||||
}
|
||||
matches, e = matcher.Match(value)
|
||||
lock.Lock()
|
||||
err = e
|
||||
lock.Unlock()
|
||||
}
|
||||
case <-contextDone:
|
||||
fail("Context was cancelled")
|
||||
return false
|
||||
case <-timeout:
|
||||
return true
|
||||
}
|
||||
|
29
vendor/github.com/onsi/gomega/internal/gomega.go
generated
vendored
29
vendor/github.com/onsi/gomega/internal/gomega.go
generated
vendored
@ -1,6 +1,7 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/gomega/types"
|
||||
@ -55,9 +56,19 @@ func (g *Gomega) Eventually(actual interface{}, intervals ...interface{}) types.
|
||||
return g.EventuallyWithOffset(0, actual, intervals...)
|
||||
}
|
||||
|
||||
func (g *Gomega) EventuallyWithOffset(offset int, actual interface{}, intervals ...interface{}) types.AsyncAssertion {
|
||||
func (g *Gomega) EventuallyWithOffset(offset int, actual interface{}, args ...interface{}) types.AsyncAssertion {
|
||||
timeoutInterval := g.DurationBundle.EventuallyTimeout
|
||||
pollingInterval := g.DurationBundle.EventuallyPollingInterval
|
||||
intervals := []interface{}{}
|
||||
var ctx context.Context
|
||||
for _, arg := range args {
|
||||
switch v := arg.(type) {
|
||||
case context.Context:
|
||||
ctx = v
|
||||
default:
|
||||
intervals = append(intervals, arg)
|
||||
}
|
||||
}
|
||||
if len(intervals) > 0 {
|
||||
timeoutInterval = toDuration(intervals[0])
|
||||
}
|
||||
@ -65,16 +76,26 @@ func (g *Gomega) EventuallyWithOffset(offset int, actual interface{}, intervals
|
||||
pollingInterval = toDuration(intervals[1])
|
||||
}
|
||||
|
||||
return NewAsyncAssertion(AsyncAssertionTypeEventually, actual, g, timeoutInterval, pollingInterval, offset)
|
||||
return NewAsyncAssertion(AsyncAssertionTypeEventually, actual, g, timeoutInterval, pollingInterval, ctx, offset)
|
||||
}
|
||||
|
||||
func (g *Gomega) Consistently(actual interface{}, intervals ...interface{}) types.AsyncAssertion {
|
||||
return g.ConsistentlyWithOffset(0, actual, intervals...)
|
||||
}
|
||||
|
||||
func (g *Gomega) ConsistentlyWithOffset(offset int, actual interface{}, intervals ...interface{}) types.AsyncAssertion {
|
||||
func (g *Gomega) ConsistentlyWithOffset(offset int, actual interface{}, args ...interface{}) types.AsyncAssertion {
|
||||
timeoutInterval := g.DurationBundle.ConsistentlyDuration
|
||||
pollingInterval := g.DurationBundle.ConsistentlyPollingInterval
|
||||
intervals := []interface{}{}
|
||||
var ctx context.Context
|
||||
for _, arg := range args {
|
||||
switch v := arg.(type) {
|
||||
case context.Context:
|
||||
ctx = v
|
||||
default:
|
||||
intervals = append(intervals, arg)
|
||||
}
|
||||
}
|
||||
if len(intervals) > 0 {
|
||||
timeoutInterval = toDuration(intervals[0])
|
||||
}
|
||||
@ -82,7 +103,7 @@ func (g *Gomega) ConsistentlyWithOffset(offset int, actual interface{}, interval
|
||||
pollingInterval = toDuration(intervals[1])
|
||||
}
|
||||
|
||||
return NewAsyncAssertion(AsyncAssertionTypeConsistently, actual, g, timeoutInterval, pollingInterval, offset)
|
||||
return NewAsyncAssertion(AsyncAssertionTypeConsistently, actual, g, timeoutInterval, pollingInterval, ctx, offset)
|
||||
}
|
||||
|
||||
func (g *Gomega) SetDefaultEventuallyTimeout(t time.Duration) {
|
||||
|
Reference in New Issue
Block a user