dependencies: ginkgo v2.9.1, gomega v1.27.4

They contain some nice-to-have improvements (for example, better printing of
errors with gomega/format.Object) but nothing that is critical right now.

"go mod tidy" was run manually in
staging/src/k8s.io/kms/internal/plugins/mock (https://github.com/kubernetes/kubernetes/pull/116613
not merged yet).
This commit is contained in:
Patrick Ohly
2023-03-13 16:06:20 +01:00
parent fcf5d23e68
commit fe59e091eb
202 changed files with 3630 additions and 1859 deletions

View File

@@ -1,3 +1,52 @@
## 1.27.4
### Fixes
- improve error formatting and remove duplication of error message in Eventually/Consistently [854f075]
### Maintenance
- Bump github.com/onsi/ginkgo/v2 from 2.9.0 to 2.9.1 (#650) [ccebd9b]
## 1.27.3
### Fixes
- format.Object now always includes err.Error() when passed an error [86d97ef]
- Fix HaveExactElements to work inside ContainElement or other collection matchers (#648) [636757e]
### Maintenance
- Bump github.com/golang/protobuf from 1.5.2 to 1.5.3 (#649) [cc16689]
- Bump github.com/onsi/ginkgo/v2 from 2.8.4 to 2.9.0 (#646) [e783366]
## 1.27.2
### Fixes
- improve poll progress message when polling a consistently that has been passing [28a319b]
### Maintenance
- bump ginkgo
- remove tools.go hack as Ginkgo 2.8.2 automatically pulls in the cli dependencies [81443b3]
## 1.27.1
### Maintenance
- Bump golang.org/x/net from 0.6.0 to 0.7.0 (#640) [bc686cd]
## 1.27.0
### Features
- Add HaveExactElements matcher (#634) [9d50783]
- update Gomega docs to discuss GinkgoHelper() [be32774]
### Maintenance
- Bump github.com/onsi/ginkgo/v2 from 2.8.0 to 2.8.1 (#639) [296a68b]
- Bump golang.org/x/net from 0.5.0 to 0.6.0 (#638) [c2b098b]
- Bump github-pages from 227 to 228 in /docs (#636) [a9069ab]
- test: update matrix for Go 1.20 (#635) [6bd25c8]
- Bump github.com/onsi/ginkgo/v2 from 2.7.0 to 2.8.0 (#631) [5445f8b]
- Bump webrick from 1.7.0 to 1.8.1 in /docs (#630) [03e93bb]
- codeql: add ruby language (#626) [63c7d21]
- dependabot: add bundler package-ecosystem for docs (#625) [d92f963]
## 1.26.0
### Features

View File

@@ -52,7 +52,7 @@ var CharactersAroundMismatchToInclude uint = 5
var contextType = reflect.TypeOf((*context.Context)(nil)).Elem()
var timeType = reflect.TypeOf(time.Time{})
//The default indentation string emitted by the format package
// The default indentation string emitted by the format package
var Indent = " "
var longFormThreshold = 20
@@ -258,7 +258,11 @@ Set PrintContextObjects to true to print the content of objects implementing con
func Object(object interface{}, indentation uint) string {
indent := strings.Repeat(Indent, int(indentation))
value := reflect.ValueOf(object)
return fmt.Sprintf("%s<%s>: %s", indent, formatType(value), formatValue(value, indentation))
commonRepresentation := ""
if err, ok := object.(error); ok {
commonRepresentation += "\n" + IndentString(err.Error(), indentation) + "\n" + indent
}
return fmt.Sprintf("%s<%s>: %s%s", indent, formatType(value), commonRepresentation, formatValue(value, indentation))
}
/*

View File

@@ -22,7 +22,7 @@ import (
"github.com/onsi/gomega/types"
)
const GOMEGA_VERSION = "1.26.0"
const GOMEGA_VERSION = "1.27.4"
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().
@@ -204,7 +204,7 @@ func Ω(actual interface{}, extra ...interface{}) Assertion {
// All subsequent arguments will be required to be nil/zero.
//
// This is convenient if you want to make an assertion on a method/function that returns
// a value and an error - a common patter in Go.
// a value and an error - a common pattern in Go.
//
// For example, given a function with signature:
//

View File

@@ -412,7 +412,7 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
message += format.Object(attachment.Object, 1)
}
} else {
message = preamble + "\n" + err.Error() + "\n" + format.Object(err, 1)
message = preamble + "\n" + format.Object(err, 1)
}
return message
}
@@ -425,10 +425,18 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
if actualErr == nil {
if matcherErr == nil {
if desiredMatch {
message += matcher.FailureMessage(actual)
if desiredMatch != matches {
if desiredMatch {
message += matcher.FailureMessage(actual)
} else {
message += matcher.NegatedFailureMessage(actual)
}
} else {
message += matcher.NegatedFailureMessage(actual)
if assertion.asyncType == AsyncAssertionTypeConsistently {
message += "There is no failure as the matcher passed to Consistently has not yet failed"
} else {
message += "There is no failure as the matcher passed to Eventually succeeded on its most recent iteration"
}
}
} else {
var fgErr formattedGomegaError

View File

@@ -349,6 +349,20 @@ func ConsistOf(elements ...interface{}) types.GomegaMatcher {
}
}
// HaveExactElemets succeeds if actual contains elements that precisely match the elemets passed into the matcher. The ordering of the elements does matter.
// By default HaveExactElements() uses Equal() to match the elements, however custom matchers can be passed in instead. Here are some examples:
//
// Expect([]string{"Foo", "FooBar"}).Should(HaveExactElements("Foo", "FooBar"))
// Expect([]string{"Foo", "FooBar"}).Should(HaveExactElements("Foo", ContainSubstring("Bar")))
// Expect([]string{"Foo", "FooBar"}).Should(HaveExactElements(ContainSubstring("Foo"), ContainSubstring("Foo")))
//
// Actual must be an array or slice.
func HaveExactElements(elements ...interface{}) types.GomegaMatcher {
return &matchers.HaveExactElementsMatcher{
Elements: elements,
}
}
// ContainElements succeeds if actual contains the passed in elements. The ordering of the elements does not matter.
// By default ContainElements() uses Equal() to match the elements, however custom matchers can be passed in instead. Here are some examples:
//

View File

@@ -0,0 +1,83 @@
package matchers
import (
"fmt"
"github.com/onsi/gomega/format"
)
type mismatchFailure struct {
failure string
index int
}
type HaveExactElementsMatcher struct {
Elements []interface{}
mismatchFailures []mismatchFailure
missingIndex int
extraIndex int
}
func (matcher *HaveExactElementsMatcher) Match(actual interface{}) (success bool, err error) {
matcher.resetState()
if isMap(actual) {
return false, fmt.Errorf("error")
}
matchers := matchers(matcher.Elements)
values := valuesOf(actual)
lenMatchers := len(matchers)
lenValues := len(values)
for i := 0; i < lenMatchers || i < lenValues; i++ {
if i >= lenMatchers {
matcher.extraIndex = i
continue
}
if i >= lenValues {
matcher.missingIndex = i
return
}
elemMatcher := matchers[i].(omegaMatcher)
match, err := elemMatcher.Match(values[i])
if err != nil || !match {
matcher.mismatchFailures = append(matcher.mismatchFailures, mismatchFailure{
index: i,
failure: elemMatcher.FailureMessage(values[i]),
})
}
}
return matcher.missingIndex+matcher.extraIndex+len(matcher.mismatchFailures) == 0, nil
}
func (matcher *HaveExactElementsMatcher) FailureMessage(actual interface{}) (message string) {
message = format.Message(actual, "to have exact elements with", presentable(matcher.Elements))
if matcher.missingIndex > 0 {
message = fmt.Sprintf("%s\nthe missing elements start from index %d", message, matcher.missingIndex)
}
if matcher.extraIndex > 0 {
message = fmt.Sprintf("%s\nthe extra elements start from index %d", message, matcher.extraIndex)
}
if len(matcher.mismatchFailures) != 0 {
message = fmt.Sprintf("%s\nthe mismatch indexes were:", message)
}
for _, mismatch := range matcher.mismatchFailures {
message = fmt.Sprintf("%s\n%d: %s", message, mismatch.index, mismatch.failure)
}
return
}
func (matcher *HaveExactElementsMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to contain elements", presentable(matcher.Elements))
}
func (matcher *HaveExactElementsMatcher) resetState() {
matcher.mismatchFailures = nil
matcher.missingIndex = 0
matcher.extraIndex = 0
}

View File

@@ -31,5 +31,5 @@ func (matcher *HaveOccurredMatcher) FailureMessage(actual interface{}) (message
}
func (matcher *HaveOccurredMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Unexpected error:\n%s\n%s\n%s", format.Object(actual, 1), format.IndentString(actual.(error).Error(), 1), "occurred")
return fmt.Sprintf("Unexpected error:\n%s\n%s", format.Object(actual, 1), "occurred")
}

View File

@@ -34,7 +34,7 @@ func (matcher *SucceedMatcher) FailureMessage(actual interface{}) (message strin
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", format.Object(actual, 1))
}
func (matcher *SucceedMatcher) NegatedFailureMessage(actual interface{}) (message string) {

View File

@@ -1,8 +0,0 @@
//go:build tools
// +build tools
package main
import (
_ "github.com/onsi/ginkgo/v2/ginkgo"
)