mirror of https://github.com/containers/podman.git
Merge pull request #17195 from containers/dependabot/go_modules/github.com/onsi/gomega-1.26.0
build(deps): bump github.com/onsi/gomega from 1.25.0 to 1.26.0
This commit is contained in:
commit
c4378f97fa
2
go.mod
2
go.mod
|
@ -41,7 +41,7 @@ require (
|
||||||
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
|
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
|
||||||
github.com/nxadm/tail v1.4.8
|
github.com/nxadm/tail v1.4.8
|
||||||
github.com/onsi/ginkgo v1.16.5
|
github.com/onsi/ginkgo v1.16.5
|
||||||
github.com/onsi/gomega v1.25.0
|
github.com/onsi/gomega v1.26.0
|
||||||
github.com/opencontainers/go-digest v1.0.0
|
github.com/opencontainers/go-digest v1.0.0
|
||||||
github.com/opencontainers/image-spec v1.1.0-rc2
|
github.com/opencontainers/image-spec v1.1.0-rc2
|
||||||
github.com/opencontainers/runc v1.1.4
|
github.com/opencontainers/runc v1.1.4
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -819,8 +819,8 @@ github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoT
|
||||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||||
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
|
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
|
||||||
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.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
|
github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q=
|
||||||
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
|
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-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 v0.0.0-20180430190053-c9281466c8b2/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-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||||
|
|
|
@ -4,3 +4,4 @@
|
||||||
.idea
|
.idea
|
||||||
gomega.iml
|
gomega.iml
|
||||||
TODO.md
|
TODO.md
|
||||||
|
.vscode
|
|
@ -1,3 +1,13 @@
|
||||||
|
## 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
|
## 1.25.0
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
"github.com/onsi/gomega/types"
|
"github.com/onsi/gomega/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const GOMEGA_VERSION = "1.25.0"
|
const GOMEGA_VERSION = "1.26.0"
|
||||||
|
|
||||||
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().
|
||||||
|
|
|
@ -2,6 +2,7 @@ package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -16,6 +17,22 @@ var errInterface = reflect.TypeOf((*error)(nil)).Elem()
|
||||||
var gomegaType = reflect.TypeOf((*types.Gomega)(nil)).Elem()
|
var gomegaType = reflect.TypeOf((*types.Gomega)(nil)).Elem()
|
||||||
var contextType = reflect.TypeOf(new(context.Context)).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 {
|
type contextWithAttachProgressReporter interface {
|
||||||
AttachProgressReporter(func() string) func()
|
AttachProgressReporter(func() string) func()
|
||||||
}
|
}
|
||||||
|
@ -148,7 +165,9 @@ func (assertion *AsyncAssertion) buildDescription(optionalDescription ...interfa
|
||||||
|
|
||||||
func (assertion *AsyncAssertion) processReturnValues(values []reflect.Value) (interface{}, error) {
|
func (assertion *AsyncAssertion) processReturnValues(values []reflect.Value) (interface{}, error) {
|
||||||
if len(values) == 0 {
|
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()
|
actual := values[0].Interface()
|
||||||
|
@ -171,10 +190,12 @@ func (assertion *AsyncAssertion) processReturnValues(values []reflect.Value) (in
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if i == len(values)-2 && extraType.Implements(errInterface) {
|
if i == len(values)-2 && extraType.Implements(errInterface) {
|
||||||
err = fmt.Errorf("function returned error: %w", extra.(error))
|
err = extra.(error)
|
||||||
}
|
}
|
||||||
if err == nil {
|
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)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +274,9 @@ func (assertion *AsyncAssertion) buildActualPoller() (func() (interface{}, error
|
||||||
skip = callerSkip[0]
|
skip = callerSkip[0]
|
||||||
}
|
}
|
||||||
_, file, line, _ := runtime.Caller(skip + 1)
|
_, 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
|
// we throw an asyncGomegaHaltExecutionError so that defer GinkgoRecover() can catch this error if the user makes an assertion in a goroutine
|
||||||
panic(asyncGomegaHaltExecutionError{})
|
panic(asyncGomegaHaltExecutionError{})
|
||||||
})))
|
})))
|
||||||
|
@ -359,22 +382,39 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||||
timeout := assertion.afterTimeout()
|
timeout := assertion.afterTimeout()
|
||||||
lock := sync.Mutex{}
|
lock := sync.Mutex{}
|
||||||
|
|
||||||
var matches bool
|
var matches, hasLastValidActual bool
|
||||||
var err error
|
var actual, lastValidActual interface{}
|
||||||
|
var actualErr, matcherErr error
|
||||||
var oracleMatcherSaysStop bool
|
var oracleMatcherSaysStop bool
|
||||||
|
|
||||||
assertion.g.THelper()
|
assertion.g.THelper()
|
||||||
|
|
||||||
pollActual, err := assertion.buildActualPoller()
|
pollActual, buildActualPollerErr := assertion.buildActualPoller()
|
||||||
if err != nil {
|
if buildActualPollerErr != nil {
|
||||||
assertion.g.Fail(err.Error(), 2+assertion.offset)
|
assertion.g.Fail(buildActualPollerErr.Error(), 2+assertion.offset)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
value, err := pollActual()
|
actual, actualErr = pollActual()
|
||||||
if err == nil {
|
if actualErr == nil {
|
||||||
oracleMatcherSaysStop = assertion.matcherSaysStopTrying(matcher, value)
|
lastValidActual = actual
|
||||||
matches, err = assertion.pollMatcher(matcher, value)
|
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 {
|
messageGenerator := func() string {
|
||||||
|
@ -382,23 +422,45 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
message := ""
|
message := ""
|
||||||
if err != nil {
|
|
||||||
if pollingSignalErr, ok := AsPollingSignalError(err); ok && pollingSignalErr.IsStopTrying() {
|
if actualErr == nil {
|
||||||
message = err.Error()
|
if matcherErr == nil {
|
||||||
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 desiredMatch {
|
if desiredMatch {
|
||||||
message = matcher.FailureMessage(value)
|
message += matcher.FailureMessage(actual)
|
||||||
} else {
|
} 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...)
|
description := assertion.buildDescription(optionalDescription...)
|
||||||
return fmt.Sprintf("%s%s", description, message)
|
return fmt.Sprintf("%s%s", description, message)
|
||||||
}
|
}
|
||||||
|
@ -423,6 +485,7 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||||
var nextPoll <-chan time.Time = nil
|
var nextPoll <-chan time.Time = nil
|
||||||
var isTryAgainAfterError = false
|
var isTryAgainAfterError = false
|
||||||
|
|
||||||
|
for _, err := range []error{actualErr, matcherErr} {
|
||||||
if pollingSignalErr, ok := AsPollingSignalError(err); ok {
|
if pollingSignalErr, ok := AsPollingSignalError(err); ok {
|
||||||
if pollingSignalErr.IsStopTrying() {
|
if pollingSignalErr.IsStopTrying() {
|
||||||
fail("Told to stop trying")
|
fail("Told to stop trying")
|
||||||
|
@ -433,8 +496,9 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||||
isTryAgainAfterError = true
|
isTryAgainAfterError = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err == nil && matches == desiredMatch {
|
if actualErr == nil && matcherErr == nil && matches == desiredMatch {
|
||||||
if assertion.asyncType == AsyncAssertionTypeEventually {
|
if assertion.asyncType == AsyncAssertionTypeEventually {
|
||||||
passedRepeatedlyCount += 1
|
passedRepeatedlyCount += 1
|
||||||
if passedRepeatedlyCount == assertion.mustPassRepeatedly {
|
if passedRepeatedlyCount == assertion.mustPassRepeatedly {
|
||||||
|
@ -465,15 +529,19 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-nextPoll:
|
case <-nextPoll:
|
||||||
v, e := pollActual()
|
a, e := pollActual()
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
value, err = v, e
|
actual, actualErr = a, e
|
||||||
lock.Unlock()
|
lock.Unlock()
|
||||||
if err == nil {
|
if actualErr == nil {
|
||||||
oracleMatcherSaysStop = assertion.matcherSaysStopTrying(matcher, value)
|
|
||||||
m, e := assertion.pollMatcher(matcher, value)
|
|
||||||
lock.Lock()
|
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()
|
lock.Unlock()
|
||||||
}
|
}
|
||||||
case <-contextDone:
|
case <-contextDone:
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/onsi/gomega/format"
|
"github.com/onsi/gomega/format"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type formattedGomegaError interface {
|
||||||
|
FormattedGomegaError() string
|
||||||
|
}
|
||||||
|
|
||||||
type SucceedMatcher struct {
|
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) {
|
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))
|
return fmt.Sprintf("Expected success, but got an error:\n%s\n%s", format.Object(actual, 1), format.IndentString(actual.(error).Error(), 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -639,7 +639,7 @@ github.com/onsi/ginkgo/reporters/stenographer
|
||||||
github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable
|
github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable
|
||||||
github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty
|
github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty
|
||||||
github.com/onsi/ginkgo/types
|
github.com/onsi/ginkgo/types
|
||||||
# github.com/onsi/gomega v1.25.0
|
# github.com/onsi/gomega v1.26.0
|
||||||
## 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
|
||||||
|
|
Loading…
Reference in New Issue