build(deps): bump github.com/onsi/gomega from 1.24.2 to 1.26.0
Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.24.2 to 1.26.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.24.2...v1.26.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:
parent
98359ff8b4
commit
9a2f763345
6
go.mod
6
go.mod
@ -16,7 +16,7 @@ require (
|
||||
github.com/mattn/go-shellwords v1.0.12
|
||||
github.com/networkplumbing/go-nft v0.2.0
|
||||
github.com/onsi/ginkgo v1.16.5
|
||||
github.com/onsi/gomega v1.24.2
|
||||
github.com/onsi/gomega v1.26.0
|
||||
github.com/safchain/ethtool v0.2.0
|
||||
github.com/vishvananda/netlink v1.2.1-beta.2
|
||||
golang.org/x/sys v0.5.0
|
||||
@ -34,8 +34,8 @@ require (
|
||||
github.com/sirupsen/logrus v1.8.1 // indirect
|
||||
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect
|
||||
go.opencensus.io v0.22.3 // indirect
|
||||
golang.org/x/net v0.4.0 // indirect
|
||||
golang.org/x/text v0.5.0 // indirect
|
||||
golang.org/x/net v0.5.0 // indirect
|
||||
golang.org/x/text v0.6.0 // indirect
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
17
go.sum
17
go.sum
@ -509,8 +509,8 @@ github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7
|
||||
github.com/onsi/ginkgo/v2 v2.3.0/go.mod h1:Eew0uilEqZmIEZr8JrvYlvOM7Rr6xzTmMV8AyFNU9d0=
|
||||
github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo=
|
||||
github.com/onsi/ginkgo/v2 v2.5.0/go.mod h1:Luc4sArBICYCS8THh8v3i3i5CuSZO+RaQRaJoeNwomw=
|
||||
github.com/onsi/ginkgo/v2 v2.6.1 h1:1xQPCjcqYw/J5LchOcp4/2q/jzJFjiAOc25chhnDw+Q=
|
||||
github.com/onsi/ginkgo/v2 v2.6.1/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo=
|
||||
github.com/onsi/ginkgo/v2 v2.7.0 h1:/XxtEV3I3Eif/HobnVx9YmJgk8ENdRsuUmM+fLCFNow=
|
||||
github.com/onsi/ginkgo/v2 v2.7.0/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo=
|
||||
github.com/onsi/gomega v0.0.0-20151007035656-2152b45fa28a/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
@ -526,8 +526,8 @@ github.com/onsi/gomega v1.21.1/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8lu
|
||||
github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM=
|
||||
github.com/onsi/gomega v1.24.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg=
|
||||
github.com/onsi/gomega v1.24.1/go.mod h1:3AOiACssS3/MajrniINInwbfOOtfZvplPzuRSmvt1jM=
|
||||
github.com/onsi/gomega v1.24.2 h1:J/tulyYK6JwBldPViHJReihxxZ+22FHs0piGjQAvoUE=
|
||||
github.com/onsi/gomega v1.24.2/go.mod h1:gs3J10IS7Z7r7eXRoNJIrNqU4ToQukCJhFtKrWgHWnk=
|
||||
github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q=
|
||||
github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
|
||||
github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||
@ -791,8 +791,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
|
||||
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
||||
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||
golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
||||
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
|
||||
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
||||
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
|
||||
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@ -890,6 +890,7 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
@ -897,6 +898,7 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX
|
||||
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
|
||||
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@ -906,8 +908,9 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
|
||||
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
|
||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
1
vendor/github.com/onsi/gomega/.gitignore
generated
vendored
1
vendor/github.com/onsi/gomega/.gitignore
generated
vendored
@ -4,3 +4,4 @@
|
||||
.idea
|
||||
gomega.iml
|
||||
TODO.md
|
||||
.vscode
|
22
vendor/github.com/onsi/gomega/CHANGELOG.md
generated
vendored
22
vendor/github.com/onsi/gomega/CHANGELOG.md
generated
vendored
@ -1,3 +1,25 @@
|
||||
## 1.26.0
|
||||
|
||||
### Features
|
||||
- When a polled function returns an error, keep track of the actual and report on the matcher state of the last non-errored actual [21f3090]
|
||||
- improve eventually failure message output [c530fb3]
|
||||
|
||||
### Fixes
|
||||
- fix several documentation spelling issues [e2eff1f]
|
||||
|
||||
|
||||
## 1.25.0
|
||||
|
||||
### Features
|
||||
- add `MustPassRepeatedly(int)` to asyncAssertion (#619) [4509f72]
|
||||
- compare unwrapped errors using DeepEqual (#617) [aaeaa5d]
|
||||
|
||||
### Maintenance
|
||||
- Bump golang.org/x/net from 0.4.0 to 0.5.0 (#614) [c7cfea4]
|
||||
- Bump github.com/onsi/ginkgo/v2 from 2.6.1 to 2.7.0 (#615) [71b8adb]
|
||||
- Docs: Fix typo "MUltiple" -> "Multiple" (#616) [9351dda]
|
||||
- clean up go.sum [cd1dc1d]
|
||||
|
||||
## 1.24.2
|
||||
|
||||
### Fixes
|
||||
|
12
vendor/github.com/onsi/gomega/gomega_dsl.go
generated
vendored
12
vendor/github.com/onsi/gomega/gomega_dsl.go
generated
vendored
@ -22,7 +22,7 @@ import (
|
||||
"github.com/onsi/gomega/types"
|
||||
)
|
||||
|
||||
const GOMEGA_VERSION = "1.24.2"
|
||||
const GOMEGA_VERSION = "1.26.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().
|
||||
@ -360,6 +360,16 @@ You can also pass additional arugments to functions that take a Gomega. The onl
|
||||
g.Expect(elements).To(ConsistOf(expected))
|
||||
}).WithContext(ctx).WithArguments("/names", "Joe", "Jane", "Sam").Should(Succeed())
|
||||
|
||||
You can ensure that you get a number of consecutive successful tries before succeeding using `MustPassRepeatedly(int)`. For Example:
|
||||
|
||||
int count := 0
|
||||
Eventually(func() bool {
|
||||
count++
|
||||
return count > 2
|
||||
}).MustPassRepeatedly(2).Should(BeTrue())
|
||||
// Because we had to wait for 2 calls that returned true
|
||||
Expect(count).To(Equal(3))
|
||||
|
||||
Finally, in addition to passing timeouts and a context to Eventually you can be more explicit with Eventually's chaining configuration methods:
|
||||
|
||||
Eventually(..., "1s", "2s", ctx).Should(...)
|
||||
|
164
vendor/github.com/onsi/gomega/internal/async_assertion.go
generated
vendored
164
vendor/github.com/onsi/gomega/internal/async_assertion.go
generated
vendored
@ -2,6 +2,7 @@ package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
@ -16,6 +17,22 @@ var errInterface = reflect.TypeOf((*error)(nil)).Elem()
|
||||
var gomegaType = reflect.TypeOf((*types.Gomega)(nil)).Elem()
|
||||
var contextType = reflect.TypeOf(new(context.Context)).Elem()
|
||||
|
||||
type formattedGomegaError interface {
|
||||
FormattedGomegaError() string
|
||||
}
|
||||
|
||||
type asyncPolledActualError struct {
|
||||
message string
|
||||
}
|
||||
|
||||
func (err *asyncPolledActualError) Error() string {
|
||||
return err.message
|
||||
}
|
||||
|
||||
func (err *asyncPolledActualError) FormattedGomegaError() string {
|
||||
return err.message
|
||||
}
|
||||
|
||||
type contextWithAttachProgressReporter interface {
|
||||
AttachProgressReporter(func() string) func()
|
||||
}
|
||||
@ -57,16 +74,18 @@ type AsyncAssertion struct {
|
||||
|
||||
timeoutInterval time.Duration
|
||||
pollingInterval time.Duration
|
||||
mustPassRepeatedly int
|
||||
ctx context.Context
|
||||
offset int
|
||||
g *Gomega
|
||||
}
|
||||
|
||||
func NewAsyncAssertion(asyncType AsyncAssertionType, actualInput interface{}, g *Gomega, timeoutInterval time.Duration, pollingInterval time.Duration, ctx context.Context, offset int) *AsyncAssertion {
|
||||
func NewAsyncAssertion(asyncType AsyncAssertionType, actualInput interface{}, g *Gomega, timeoutInterval time.Duration, pollingInterval time.Duration, mustPassRepeatedly int, ctx context.Context, offset int) *AsyncAssertion {
|
||||
out := &AsyncAssertion{
|
||||
asyncType: asyncType,
|
||||
timeoutInterval: timeoutInterval,
|
||||
pollingInterval: pollingInterval,
|
||||
mustPassRepeatedly: mustPassRepeatedly,
|
||||
offset: offset,
|
||||
ctx: ctx,
|
||||
g: g,
|
||||
@ -115,6 +134,11 @@ func (assertion *AsyncAssertion) WithArguments(argsToForward ...interface{}) typ
|
||||
return assertion
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) MustPassRepeatedly(count int) types.AsyncAssertion {
|
||||
assertion.mustPassRepeatedly = count
|
||||
return assertion
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
|
||||
assertion.g.THelper()
|
||||
vetOptionalDescription("Asynchronous assertion", optionalDescription...)
|
||||
@ -141,7 +165,9 @@ func (assertion *AsyncAssertion) buildDescription(optionalDescription ...interfa
|
||||
|
||||
func (assertion *AsyncAssertion) processReturnValues(values []reflect.Value) (interface{}, error) {
|
||||
if len(values) == 0 {
|
||||
return nil, fmt.Errorf("No values were returned by the function passed to Gomega")
|
||||
return nil, &asyncPolledActualError{
|
||||
message: fmt.Sprintf("The function passed to %s did not return any values", assertion.asyncType),
|
||||
}
|
||||
}
|
||||
|
||||
actual := values[0].Interface()
|
||||
@ -164,10 +190,12 @@ func (assertion *AsyncAssertion) processReturnValues(values []reflect.Value) (in
|
||||
continue
|
||||
}
|
||||
if i == len(values)-2 && extraType.Implements(errInterface) {
|
||||
err = fmt.Errorf("function returned error: %w", extra.(error))
|
||||
err = extra.(error)
|
||||
}
|
||||
if err == nil {
|
||||
err = fmt.Errorf("Unexpected non-nil/non-zero return value at index %d:\n\t<%T>: %#v", i+1, extra, extra)
|
||||
err = &asyncPolledActualError{
|
||||
message: fmt.Sprintf("The function passed to %s had an unexpected non-nil/non-zero return value at index %d:\n%s", assertion.asyncType, i+1, format.Object(extra, 1)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,6 +230,13 @@ You can learn more at https://onsi.github.io/gomega/#eventually
|
||||
`, assertion.asyncType, t, t.NumIn(), numProvided, have, assertion.asyncType)
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) invalidMustPassRepeatedlyError(reason string) error {
|
||||
return fmt.Errorf(`Invalid use of MustPassRepeatedly with %s %s
|
||||
|
||||
You can learn more at https://onsi.github.io/gomega/#eventually
|
||||
`, assertion.asyncType, reason)
|
||||
}
|
||||
|
||||
func (assertion *AsyncAssertion) buildActualPoller() (func() (interface{}, error), error) {
|
||||
if !assertion.actualIsFunc {
|
||||
return func() (interface{}, error) { return assertion.actual, nil }, nil
|
||||
@ -239,7 +274,9 @@ func (assertion *AsyncAssertion) buildActualPoller() (func() (interface{}, error
|
||||
skip = callerSkip[0]
|
||||
}
|
||||
_, file, line, _ := runtime.Caller(skip + 1)
|
||||
assertionFailure = fmt.Errorf("Assertion in callback at %s:%d failed:\n%s", file, line, message)
|
||||
assertionFailure = &asyncPolledActualError{
|
||||
message: fmt.Sprintf("The function passed to %s failed at %s:%d with:\n%s", assertion.asyncType, file, line, message),
|
||||
}
|
||||
// we throw an asyncGomegaHaltExecutionError so that defer GinkgoRecover() can catch this error if the user makes an assertion in a goroutine
|
||||
panic(asyncGomegaHaltExecutionError{})
|
||||
})))
|
||||
@ -257,6 +294,13 @@ func (assertion *AsyncAssertion) buildActualPoller() (func() (interface{}, error
|
||||
return nil, assertion.argumentMismatchError(actualType, len(inValues))
|
||||
}
|
||||
|
||||
if assertion.mustPassRepeatedly != 1 && assertion.asyncType != AsyncAssertionTypeEventually {
|
||||
return nil, assertion.invalidMustPassRepeatedlyError("it can only be used with Eventually")
|
||||
}
|
||||
if assertion.mustPassRepeatedly < 1 {
|
||||
return nil, assertion.invalidMustPassRepeatedlyError("parameter can't be < 1")
|
||||
}
|
||||
|
||||
return func() (actual interface{}, err error) {
|
||||
var values []reflect.Value
|
||||
assertionFailure = nil
|
||||
@ -338,22 +382,39 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||
timeout := assertion.afterTimeout()
|
||||
lock := sync.Mutex{}
|
||||
|
||||
var matches bool
|
||||
var err error
|
||||
var matches, hasLastValidActual bool
|
||||
var actual, lastValidActual interface{}
|
||||
var actualErr, matcherErr error
|
||||
var oracleMatcherSaysStop bool
|
||||
|
||||
assertion.g.THelper()
|
||||
|
||||
pollActual, err := assertion.buildActualPoller()
|
||||
if err != nil {
|
||||
assertion.g.Fail(err.Error(), 2+assertion.offset)
|
||||
pollActual, buildActualPollerErr := assertion.buildActualPoller()
|
||||
if buildActualPollerErr != nil {
|
||||
assertion.g.Fail(buildActualPollerErr.Error(), 2+assertion.offset)
|
||||
return false
|
||||
}
|
||||
|
||||
value, err := pollActual()
|
||||
if err == nil {
|
||||
oracleMatcherSaysStop = assertion.matcherSaysStopTrying(matcher, value)
|
||||
matches, err = assertion.pollMatcher(matcher, value)
|
||||
actual, actualErr = pollActual()
|
||||
if actualErr == nil {
|
||||
lastValidActual = actual
|
||||
hasLastValidActual = true
|
||||
oracleMatcherSaysStop = assertion.matcherSaysStopTrying(matcher, actual)
|
||||
matches, matcherErr = assertion.pollMatcher(matcher, actual)
|
||||
}
|
||||
|
||||
renderError := func(preamble string, err error) string {
|
||||
message := ""
|
||||
if pollingSignalErr, ok := AsPollingSignalError(err); ok {
|
||||
message = err.Error()
|
||||
for _, attachment := range pollingSignalErr.Attachments {
|
||||
message += fmt.Sprintf("\n%s:\n", attachment.Description)
|
||||
message += format.Object(attachment.Object, 1)
|
||||
}
|
||||
} else {
|
||||
message = preamble + "\n" + err.Error() + "\n" + format.Object(err, 1)
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
||||
messageGenerator := func() string {
|
||||
@ -361,23 +422,45 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
message := ""
|
||||
if err != nil {
|
||||
if pollingSignalErr, ok := AsPollingSignalError(err); ok && pollingSignalErr.IsStopTrying() {
|
||||
message = err.Error()
|
||||
for _, attachment := range pollingSignalErr.Attachments {
|
||||
message += fmt.Sprintf("\n%s:\n", attachment.Description)
|
||||
message += format.Object(attachment.Object, 1)
|
||||
}
|
||||
} else {
|
||||
message = "Error: " + err.Error() + "\n" + format.Object(err, 1)
|
||||
}
|
||||
} else {
|
||||
|
||||
if actualErr == nil {
|
||||
if matcherErr == nil {
|
||||
if desiredMatch {
|
||||
message = matcher.FailureMessage(value)
|
||||
message += matcher.FailureMessage(actual)
|
||||
} else {
|
||||
message = matcher.NegatedFailureMessage(value)
|
||||
message += matcher.NegatedFailureMessage(actual)
|
||||
}
|
||||
} else {
|
||||
var fgErr formattedGomegaError
|
||||
if errors.As(actualErr, &fgErr) {
|
||||
message += fgErr.FormattedGomegaError() + "\n"
|
||||
} else {
|
||||
message += renderError(fmt.Sprintf("The matcher passed to %s returned the following error:", assertion.asyncType), matcherErr)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var fgErr formattedGomegaError
|
||||
if errors.As(actualErr, &fgErr) {
|
||||
message += fgErr.FormattedGomegaError() + "\n"
|
||||
} else {
|
||||
message += renderError(fmt.Sprintf("The function passed to %s returned the following error:", assertion.asyncType), actualErr)
|
||||
}
|
||||
if hasLastValidActual {
|
||||
message += fmt.Sprintf("\nAt one point, however, the function did return successfully.\nYet, %s failed because", assertion.asyncType)
|
||||
_, e := matcher.Match(lastValidActual)
|
||||
if e != nil {
|
||||
message += renderError(" the matcher returned the following error:", e)
|
||||
} else {
|
||||
message += " the matcher was not satisfied:\n"
|
||||
if desiredMatch {
|
||||
message += matcher.FailureMessage(lastValidActual)
|
||||
} else {
|
||||
message += matcher.NegatedFailureMessage(lastValidActual)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
description := assertion.buildDescription(optionalDescription...)
|
||||
return fmt.Sprintf("%s%s", description, message)
|
||||
}
|
||||
@ -396,10 +479,13 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||
}
|
||||
}
|
||||
|
||||
// Used to count the number of times in a row a step passed
|
||||
passedRepeatedlyCount := 0
|
||||
for {
|
||||
var nextPoll <-chan time.Time = nil
|
||||
var isTryAgainAfterError = false
|
||||
|
||||
for _, err := range []error{actualErr, matcherErr} {
|
||||
if pollingSignalErr, ok := AsPollingSignalError(err); ok {
|
||||
if pollingSignalErr.IsStopTrying() {
|
||||
fail("Told to stop trying")
|
||||
@ -410,16 +496,22 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||
isTryAgainAfterError = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err == nil && matches == desiredMatch {
|
||||
if actualErr == nil && matcherErr == nil && matches == desiredMatch {
|
||||
if assertion.asyncType == AsyncAssertionTypeEventually {
|
||||
passedRepeatedlyCount += 1
|
||||
if passedRepeatedlyCount == assertion.mustPassRepeatedly {
|
||||
return true
|
||||
}
|
||||
}
|
||||
} else if !isTryAgainAfterError {
|
||||
if assertion.asyncType == AsyncAssertionTypeConsistently {
|
||||
fail("Failed")
|
||||
return false
|
||||
}
|
||||
// Reset the consecutive pass count
|
||||
passedRepeatedlyCount = 0
|
||||
}
|
||||
|
||||
if oracleMatcherSaysStop {
|
||||
@ -437,15 +529,19 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||
|
||||
select {
|
||||
case <-nextPoll:
|
||||
v, e := pollActual()
|
||||
a, e := pollActual()
|
||||
lock.Lock()
|
||||
value, err = v, e
|
||||
actual, actualErr = a, e
|
||||
lock.Unlock()
|
||||
if err == nil {
|
||||
oracleMatcherSaysStop = assertion.matcherSaysStopTrying(matcher, value)
|
||||
m, e := assertion.pollMatcher(matcher, value)
|
||||
if actualErr == nil {
|
||||
lock.Lock()
|
||||
matches, err = m, e
|
||||
lastValidActual = actual
|
||||
hasLastValidActual = true
|
||||
lock.Unlock()
|
||||
oracleMatcherSaysStop = assertion.matcherSaysStopTrying(matcher, actual)
|
||||
m, e := assertion.pollMatcher(matcher, actual)
|
||||
lock.Lock()
|
||||
matches, matcherErr = m, e
|
||||
lock.Unlock()
|
||||
}
|
||||
case <-contextDone:
|
||||
|
2
vendor/github.com/onsi/gomega/internal/gomega.go
generated
vendored
2
vendor/github.com/onsi/gomega/internal/gomega.go
generated
vendored
@ -109,7 +109,7 @@ func (g *Gomega) makeAsyncAssertion(asyncAssertionType AsyncAssertionType, offse
|
||||
}
|
||||
}
|
||||
|
||||
return NewAsyncAssertion(asyncAssertionType, actual, g, timeoutInterval, pollingInterval, ctx, offset)
|
||||
return NewAsyncAssertion(asyncAssertionType, actual, g, timeoutInterval, pollingInterval, 1, ctx, offset)
|
||||
}
|
||||
|
||||
func (g *Gomega) SetDefaultEventuallyTimeout(t time.Duration) {
|
||||
|
12
vendor/github.com/onsi/gomega/matchers/match_error_matcher.go
generated
vendored
12
vendor/github.com/onsi/gomega/matchers/match_error_matcher.go
generated
vendored
@ -25,7 +25,17 @@ func (matcher *MatchErrorMatcher) Match(actual interface{}) (success bool, err e
|
||||
expected := matcher.Expected
|
||||
|
||||
if isError(expected) {
|
||||
return reflect.DeepEqual(actualErr, expected) || errors.Is(actualErr, expected.(error)), nil
|
||||
// first try the built-in errors.Is
|
||||
if errors.Is(actualErr, expected.(error)) {
|
||||
return true, nil
|
||||
}
|
||||
// if not, try DeepEqual along the error chain
|
||||
for unwrapped := actualErr; unwrapped != nil; unwrapped = errors.Unwrap(unwrapped) {
|
||||
if reflect.DeepEqual(unwrapped, expected) {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if isString(expected) {
|
||||
|
9
vendor/github.com/onsi/gomega/matchers/succeed_matcher.go
generated
vendored
9
vendor/github.com/onsi/gomega/matchers/succeed_matcher.go
generated
vendored
@ -1,11 +1,16 @@
|
||||
package matchers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/onsi/gomega/format"
|
||||
)
|
||||
|
||||
type formattedGomegaError interface {
|
||||
FormattedGomegaError() string
|
||||
}
|
||||
|
||||
type SucceedMatcher struct {
|
||||
}
|
||||
|
||||
@ -25,6 +30,10 @@ func (matcher *SucceedMatcher) Match(actual interface{}) (success bool, err erro
|
||||
}
|
||||
|
||||
func (matcher *SucceedMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
var fgErr formattedGomegaError
|
||||
if errors.As(actual.(error), &fgErr) {
|
||||
return fgErr.FormattedGomegaError()
|
||||
}
|
||||
return fmt.Sprintf("Expected success, but got an error:\n%s\n%s", format.Object(actual, 1), format.IndentString(actual.(error).Error(), 1))
|
||||
}
|
||||
|
||||
|
1
vendor/github.com/onsi/gomega/types/types.go
generated
vendored
1
vendor/github.com/onsi/gomega/types/types.go
generated
vendored
@ -75,6 +75,7 @@ type AsyncAssertion interface {
|
||||
ProbeEvery(interval time.Duration) AsyncAssertion
|
||||
WithContext(ctx context.Context) AsyncAssertion
|
||||
WithArguments(argsToForward ...interface{}) AsyncAssertion
|
||||
MustPassRepeatedly(count int) AsyncAssertion
|
||||
}
|
||||
|
||||
// Assertions are returned by Ω and Expect and enable assertions against Gomega matchers
|
||||
|
6
vendor/modules.txt
vendored
6
vendor/modules.txt
vendored
@ -131,7 +131,7 @@ github.com/onsi/ginkgo/reporters/stenographer
|
||||
github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable
|
||||
github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty
|
||||
github.com/onsi/ginkgo/types
|
||||
# github.com/onsi/gomega v1.24.2
|
||||
# github.com/onsi/gomega v1.26.0
|
||||
## explicit; go 1.18
|
||||
github.com/onsi/gomega
|
||||
github.com/onsi/gomega/format
|
||||
@ -168,7 +168,7 @@ go.opencensus.io/internal
|
||||
go.opencensus.io/trace
|
||||
go.opencensus.io/trace/internal
|
||||
go.opencensus.io/trace/tracestate
|
||||
# golang.org/x/net v0.4.0
|
||||
# golang.org/x/net v0.5.0
|
||||
## explicit; go 1.17
|
||||
golang.org/x/net/bpf
|
||||
golang.org/x/net/html
|
||||
@ -183,7 +183,7 @@ golang.org/x/sys/internal/unsafeheader
|
||||
golang.org/x/sys/unix
|
||||
golang.org/x/sys/windows
|
||||
golang.org/x/sys/windows/registry
|
||||
# golang.org/x/text v0.5.0
|
||||
# golang.org/x/text v0.6.0
|
||||
## explicit; go 1.17
|
||||
golang.org/x/text/encoding
|
||||
golang.org/x/text/encoding/charmap
|
||||
|
Loading…
x
Reference in New Issue
Block a user