Bump github.com/onsi/gomega from 1.34.2 to 1.35.0
Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.34.2 to 1.35.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.34.2...v1.35.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
Ralf Haferkamp
parent
30f001e3c2
commit
7e5b189685
+10
-2
@@ -335,7 +335,7 @@ func (assertion *AsyncAssertion) afterTimeout() <-chan time.Time {
|
||||
if assertion.asyncType == AsyncAssertionTypeConsistently {
|
||||
return time.After(assertion.g.DurationBundle.ConsistentlyDuration)
|
||||
} else {
|
||||
if assertion.ctx == nil {
|
||||
if assertion.ctx == nil || assertion.g.DurationBundle.EnforceDefaultTimeoutsWhenUsingContexts {
|
||||
return time.After(assertion.g.DurationBundle.EventuallyTimeout)
|
||||
} else {
|
||||
return nil
|
||||
@@ -496,7 +496,15 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||
for _, err := range []error{actualErr, matcherErr} {
|
||||
if pollingSignalErr, ok := AsPollingSignalError(err); ok {
|
||||
if pollingSignalErr.IsStopTrying() {
|
||||
fail("Told to stop trying")
|
||||
if pollingSignalErr.IsSuccessful() {
|
||||
if assertion.asyncType == AsyncAssertionTypeEventually {
|
||||
fail("Told to stop trying (and ignoring call to Successfully(), as it is only relevant with Consistently)")
|
||||
} else {
|
||||
return true // early escape hatch for Consistently
|
||||
}
|
||||
} else {
|
||||
fail("Told to stop trying")
|
||||
}
|
||||
return false
|
||||
}
|
||||
if pollingSignalErr.IsTryAgainAfter() {
|
||||
|
||||
+11
-6
@@ -8,10 +8,11 @@ import (
|
||||
)
|
||||
|
||||
type DurationBundle struct {
|
||||
EventuallyTimeout time.Duration
|
||||
EventuallyPollingInterval time.Duration
|
||||
ConsistentlyDuration time.Duration
|
||||
ConsistentlyPollingInterval time.Duration
|
||||
EventuallyTimeout time.Duration
|
||||
EventuallyPollingInterval time.Duration
|
||||
ConsistentlyDuration time.Duration
|
||||
ConsistentlyPollingInterval time.Duration
|
||||
EnforceDefaultTimeoutsWhenUsingContexts bool
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -20,15 +21,19 @@ const (
|
||||
|
||||
ConsistentlyDurationEnvVarName = "GOMEGA_DEFAULT_CONSISTENTLY_DURATION"
|
||||
ConsistentlyPollingIntervalEnvVarName = "GOMEGA_DEFAULT_CONSISTENTLY_POLLING_INTERVAL"
|
||||
|
||||
EnforceDefaultTimeoutsWhenUsingContextsEnvVarName = "GOMEGA_ENFORCE_DEFAULT_TIMEOUTS_WHEN_USING_CONTEXTS"
|
||||
)
|
||||
|
||||
func FetchDefaultDurationBundle() DurationBundle {
|
||||
_, EnforceDefaultTimeoutsWhenUsingContexts := os.LookupEnv(EnforceDefaultTimeoutsWhenUsingContextsEnvVarName)
|
||||
return DurationBundle{
|
||||
EventuallyTimeout: durationFromEnv(EventuallyTimeoutEnvVarName, time.Second),
|
||||
EventuallyPollingInterval: durationFromEnv(EventuallyPollingIntervalEnvVarName, 10*time.Millisecond),
|
||||
|
||||
ConsistentlyDuration: durationFromEnv(ConsistentlyDurationEnvVarName, 100*time.Millisecond),
|
||||
ConsistentlyPollingInterval: durationFromEnv(ConsistentlyPollingIntervalEnvVarName, 10*time.Millisecond),
|
||||
ConsistentlyDuration: durationFromEnv(ConsistentlyDurationEnvVarName, 100*time.Millisecond),
|
||||
ConsistentlyPollingInterval: durationFromEnv(ConsistentlyPollingIntervalEnvVarName, 10*time.Millisecond),
|
||||
EnforceDefaultTimeoutsWhenUsingContexts: EnforceDefaultTimeoutsWhenUsingContexts,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -127,3 +127,11 @@ func (g *Gomega) SetDefaultConsistentlyDuration(t time.Duration) {
|
||||
func (g *Gomega) SetDefaultConsistentlyPollingInterval(t time.Duration) {
|
||||
g.DurationBundle.ConsistentlyPollingInterval = t
|
||||
}
|
||||
|
||||
func (g *Gomega) EnforceDefaultTimeoutsWhenUsingContexts() {
|
||||
g.DurationBundle.EnforceDefaultTimeoutsWhenUsingContexts = true
|
||||
}
|
||||
|
||||
func (g *Gomega) DisableDefaultTimeoutsWhenUsingContext() {
|
||||
g.DurationBundle.EnforceDefaultTimeoutsWhenUsingContexts = false
|
||||
}
|
||||
|
||||
+11
@@ -17,6 +17,7 @@ type PollingSignalError interface {
|
||||
error
|
||||
Wrap(err error) PollingSignalError
|
||||
Attach(description string, obj any) PollingSignalError
|
||||
Successfully() PollingSignalError
|
||||
Now()
|
||||
}
|
||||
|
||||
@@ -45,6 +46,7 @@ type PollingSignalErrorImpl struct {
|
||||
wrappedErr error
|
||||
pollingSignalErrorType PollingSignalErrorType
|
||||
duration time.Duration
|
||||
successful bool
|
||||
Attachments []PollingSignalErrorAttachment
|
||||
}
|
||||
|
||||
@@ -73,6 +75,11 @@ func (s *PollingSignalErrorImpl) Unwrap() error {
|
||||
return s.wrappedErr
|
||||
}
|
||||
|
||||
func (s *PollingSignalErrorImpl) Successfully() PollingSignalError {
|
||||
s.successful = true
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *PollingSignalErrorImpl) Now() {
|
||||
panic(s)
|
||||
}
|
||||
@@ -81,6 +88,10 @@ func (s *PollingSignalErrorImpl) IsStopTrying() bool {
|
||||
return s.pollingSignalErrorType == PollingSignalErrorTypeStopTrying
|
||||
}
|
||||
|
||||
func (s *PollingSignalErrorImpl) IsSuccessful() bool {
|
||||
return s.successful
|
||||
}
|
||||
|
||||
func (s *PollingSignalErrorImpl) IsTryAgainAfter() bool {
|
||||
return s.pollingSignalErrorType == PollingSignalErrorTypeTryAgainAfter
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user