diff --git a/go.mod b/go.mod index b6d9dc10c..75e02996f 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.25.6 require ( github.com/google/go-containerregistry v0.21.2 - github.com/onsi/gomega v1.39.1 + github.com/onsi/gomega v1.41.0 github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 github.com/schollz/progressbar/v3 v3.19.0 github.com/shipwright-io/build v0.19.0 diff --git a/go.sum b/go.sum index 7393d314a..d61f8ea9a 100644 --- a/go.sum +++ b/go.sum @@ -334,8 +334,8 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/onsi/ginkgo/v2 v2.28.1 h1:S4hj+HbZp40fNKuLUQOYLDgZLwNUVn19N3Atb98NCyI= github.com/onsi/ginkgo/v2 v2.28.1/go.mod h1:CLtbVInNckU3/+gC8LzkGUb9oF+e8W8TdUsxPwvdOgE= -github.com/onsi/gomega v1.39.1 h1:1IJLAad4zjPn2PsnhH70V4DKRFlrCzGBNrNaru+Vf28= -github.com/onsi/gomega v1.39.1/go.mod h1:hL6yVALoTOxeWudERyfppUcZXjMwIMLnuSfruD2lcfg= +github.com/onsi/gomega v1.41.0 h1:OwKp4pXNgVxf6sCplzYo794OFNuoL2q2SBMU5NSWOjA= +github.com/onsi/gomega v1.41.0/go.mod h1:M/Uqpu/8qTjtzCLUA2zJHX9Iilrau25x1PdoSRbWh5A= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= diff --git a/vendor/github.com/onsi/gomega/CHANGELOG.md b/vendor/github.com/onsi/gomega/CHANGELOG.md index 91e65521b..5f9966fbe 100644 --- a/vendor/github.com/onsi/gomega/CHANGELOG.md +++ b/vendor/github.com/onsi/gomega/CHANGELOG.md @@ -1,3 +1,21 @@ +## 1.41.0 + +### Features + +Add `BeASlice` and `BeAnArray` matchers + +### Fixes + +Object formatting now detects pointer cycles to avoid runaway formatting output. + +## 1.40.0 + +We're adopting a new release strategy to minimize dependency bloat in projects that consume Gomega. It is a limitation of the go mod toolchain that _test_ subdependencies of your project's direct dependencies get pulled in as *indirect* dependencies. In the case of Gomega, this ends up pulling in all of Ginkgo into your `go.mod` even if you are only using Gomega (Gomega uses Ginkgo for its own tests). + +Going forward, releases will strip out all tests, tidy up the `go.mod` and then push this stripped down version to a new `master-lite` branch. These stripped-down versions will receive the `vx.y.z` git tag and will be picked up by the go toolchain. + +Please open an issue if this new release process causes unexpected changes for your projects. + ## 1.39.1 Update all dependencies. This auto-updated the required version of Go to 1.24, consistent with the fact that Go 1.23 has been out of support for almost six months. diff --git a/vendor/github.com/onsi/gomega/format/format.go b/vendor/github.com/onsi/gomega/format/format.go index 6c23ba338..d56f9a475 100644 --- a/vendor/github.com/onsi/gomega/format/format.go +++ b/vendor/github.com/onsi/gomega/format/format.go @@ -262,7 +262,7 @@ func Object(object any, indentation uint) string { if err, ok := object.(error); ok && !isNilValue(value) { // isNilValue check needed here to avoid nil deref due to boxed nil commonRepresentation += "\n" + IndentString(err.Error(), indentation) + "\n" + indent } - return fmt.Sprintf("%s<%s>: %s%s", indent, formatType(value), commonRepresentation, formatValue(value, indentation, true)) + return fmt.Sprintf("%s<%s>: %s%s", indent, formatType(value), commonRepresentation, formatValue(value, indentation, true, map[uintptr]struct{}{})) } /* @@ -306,7 +306,7 @@ func formatType(v reflect.Value) string { } } -func formatValue(value reflect.Value, indentation uint, isTopLevel bool) string { +func formatValue(value reflect.Value, indentation uint, isTopLevel bool, visited map[uintptr]struct{}) string { if indentation > MaxDepth { return "..." } @@ -367,23 +367,28 @@ func formatValue(value reflect.Value, indentation uint, isTopLevel bool) string case reflect.Func: return fmt.Sprintf("0x%x", value.Pointer()) case reflect.Ptr: - return formatValue(value.Elem(), indentation, isTopLevel) + ptr := value.Pointer() + if _, ok := visited[ptr]; ok { + return fmt.Sprintf("0x%x (cyclic reference)", ptr) + } + visited[ptr] = struct{}{} + return formatValue(value.Elem(), indentation, isTopLevel, visited) case reflect.Slice: - return truncateLongStrings(formatSlice(value, indentation)) + return truncateLongStrings(formatSlice(value, indentation, visited)) case reflect.String: return truncateLongStrings(formatString(value.String(), indentation, isTopLevel)) case reflect.Array: - return truncateLongStrings(formatSlice(value, indentation)) + return truncateLongStrings(formatSlice(value, indentation, visited)) case reflect.Map: - return truncateLongStrings(formatMap(value, indentation)) + return truncateLongStrings(formatMap(value, indentation, visited)) case reflect.Struct: if value.Type() == timeType && value.CanInterface() { t, _ := value.Interface().(time.Time) return t.Format(time.RFC3339Nano) } - return truncateLongStrings(formatStruct(value, indentation)) + return truncateLongStrings(formatStruct(value, indentation, visited)) case reflect.Interface: - return formatInterface(value, indentation) + return formatInterface(value, indentation, visited) default: if value.CanInterface() { return truncateLongStrings(fmt.Sprintf("%#v", value.Interface())) @@ -414,7 +419,7 @@ func formatString(object any, indentation uint, isTopLevel bool) string { } } -func formatSlice(v reflect.Value, indentation uint) string { +func formatSlice(v reflect.Value, indentation uint, visited map[uintptr]struct{}) string { if v.Kind() == reflect.Slice && v.Type().Elem().Kind() == reflect.Uint8 && isPrintableString(string(v.Bytes())) { return formatString(v.Bytes(), indentation, false) } @@ -423,7 +428,7 @@ func formatSlice(v reflect.Value, indentation uint) string { result := make([]string, l) longest := 0 for i := range l { - result[i] = formatValue(v.Index(i), indentation+1, false) + result[i] = formatValue(v.Index(i), indentation+1, false, visited) if len(result[i]) > longest { longest = len(result[i]) } @@ -436,14 +441,14 @@ func formatSlice(v reflect.Value, indentation uint) string { return fmt.Sprintf("[%s]", strings.Join(result, ", ")) } -func formatMap(v reflect.Value, indentation uint) string { +func formatMap(v reflect.Value, indentation uint, visited map[uintptr]struct{}) string { l := v.Len() result := make([]string, l) longest := 0 for i, key := range v.MapKeys() { value := v.MapIndex(key) - result[i] = fmt.Sprintf("%s: %s", formatValue(key, indentation+1, false), formatValue(value, indentation+1, false)) + result[i] = fmt.Sprintf("%s: %s", formatValue(key, indentation+1, false, visited), formatValue(value, indentation+1, false, visited)) if len(result[i]) > longest { longest = len(result[i]) } @@ -456,7 +461,7 @@ func formatMap(v reflect.Value, indentation uint) string { return fmt.Sprintf("{%s}", strings.Join(result, ", ")) } -func formatStruct(v reflect.Value, indentation uint) string { +func formatStruct(v reflect.Value, indentation uint, visited map[uintptr]struct{}) string { t := v.Type() l := v.NumField() @@ -465,7 +470,7 @@ func formatStruct(v reflect.Value, indentation uint) string { for i := range l { structField := t.Field(i) fieldEntry := v.Field(i) - representation := fmt.Sprintf("%s: %s", structField.Name, formatValue(fieldEntry, indentation+1, false)) + representation := fmt.Sprintf("%s: %s", structField.Name, formatValue(fieldEntry, indentation+1, false, visited)) result = append(result, representation) if len(representation) > longest { longest = len(representation) @@ -478,8 +483,8 @@ func formatStruct(v reflect.Value, indentation uint) string { return fmt.Sprintf("{%s}", strings.Join(result, ", ")) } -func formatInterface(v reflect.Value, indentation uint) string { - return fmt.Sprintf("<%s>%s", formatType(v.Elem()), formatValue(v.Elem(), indentation, false)) +func formatInterface(v reflect.Value, indentation uint, visited map[uintptr]struct{}) string { + return fmt.Sprintf("<%s>%s", formatType(v.Elem()), formatValue(v.Elem(), indentation, false, visited)) } func isNilValue(a reflect.Value) bool { diff --git a/vendor/github.com/onsi/gomega/gomega_dsl.go b/vendor/github.com/onsi/gomega/gomega_dsl.go index 87c70692b..df16ede11 100644 --- a/vendor/github.com/onsi/gomega/gomega_dsl.go +++ b/vendor/github.com/onsi/gomega/gomega_dsl.go @@ -22,7 +22,7 @@ import ( "github.com/onsi/gomega/types" ) -const GOMEGA_VERSION = "1.39.1" +const GOMEGA_VERSION = "1.41.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(). diff --git a/vendor/github.com/onsi/gomega/matchers.go b/vendor/github.com/onsi/gomega/matchers.go index 16ca8f46d..bf5722605 100644 --- a/vendor/github.com/onsi/gomega/matchers.go +++ b/vendor/github.com/onsi/gomega/matchers.go @@ -621,6 +621,18 @@ func BeADirectory() types.GomegaMatcher { return &matchers.BeADirectoryMatcher{} } +// BeASlice succeeds if actual is a value of slice type. +// This is useful when actual has type any (interface{}) and you want to assert it is a slice. +func BeASlice() types.GomegaMatcher { + return &matchers.BeASliceMatcher{} +} + +// BeAnArray succeeds if actual is a value of array type. +// This is useful when actual has type any (interface{}) and you want to assert it is an array. +func BeAnArray() types.GomegaMatcher { + return &matchers.BeAnArrayMatcher{} +} + // HaveHTTPStatus succeeds if the Status or StatusCode field of an HTTP response matches. // Actual must be either a *http.Response or *httptest.ResponseRecorder. // Expected must be either an int or a string. diff --git a/vendor/github.com/onsi/gomega/matchers/be_a_slice_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_a_slice_matcher.go new file mode 100644 index 000000000..4fcad5127 --- /dev/null +++ b/vendor/github.com/onsi/gomega/matchers/be_a_slice_matcher.go @@ -0,0 +1,28 @@ +// untested sections: 1 + +package matchers + +import ( + "fmt" + "reflect" + + "github.com/onsi/gomega/format" +) + +type BeASliceMatcher struct { +} + +func (matcher *BeASliceMatcher) Match(actual any) (success bool, err error) { + if actual == nil { + return false, fmt.Errorf("BeASlice matcher expects a value, got nil") + } + return reflect.TypeOf(actual).Kind() == reflect.Slice, nil +} + +func (matcher *BeASliceMatcher) FailureMessage(actual any) (message string) { + return format.Message(actual, "to be a slice") +} + +func (matcher *BeASliceMatcher) NegatedFailureMessage(actual any) (message string) { + return format.Message(actual, "not to be a slice") +} diff --git a/vendor/github.com/onsi/gomega/matchers/be_an_array_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_an_array_matcher.go new file mode 100644 index 000000000..573aa8198 --- /dev/null +++ b/vendor/github.com/onsi/gomega/matchers/be_an_array_matcher.go @@ -0,0 +1,28 @@ +// untested sections: 1 + +package matchers + +import ( + "fmt" + "reflect" + + "github.com/onsi/gomega/format" +) + +type BeAnArrayMatcher struct { +} + +func (matcher *BeAnArrayMatcher) Match(actual any) (success bool, err error) { + if actual == nil { + return false, fmt.Errorf("BeAnArray matcher expects a value, got nil") + } + return reflect.TypeOf(actual).Kind() == reflect.Array, nil +} + +func (matcher *BeAnArrayMatcher) FailureMessage(actual any) (message string) { + return format.Message(actual, "to be an array") +} + +func (matcher *BeAnArrayMatcher) NegatedFailureMessage(actual any) (message string) { + return format.Message(actual, "not to be an array") +} diff --git a/vendor/github.com/onsi/gomega/types/types.go b/vendor/github.com/onsi/gomega/types/types.go index 685a46f37..e444451ac 100644 --- a/vendor/github.com/onsi/gomega/types/types.go +++ b/vendor/github.com/onsi/gomega/types/types.go @@ -66,6 +66,12 @@ func MatchMayChangeInTheFuture(matcher GomegaMatcher, value any) bool { // AsyncAssertions are returned by Eventually and Consistently and enable matchers to be polled repeatedly to ensure // they are eventually satisfied +// +// The optional optionalDescription argument allows you to annotate the assertion with additional information. +// It is passed as the second argument and can be a format string followed by arguments, or a func() string. +// The description is included in failure messages to provide context. +// +// For details on annotating assertions, see: https://onsi.github.io/gomega/#annotating-assertions type AsyncAssertion interface { Should(matcher GomegaMatcher, optionalDescription ...any) bool ShouldNot(matcher GomegaMatcher, optionalDescription ...any) bool @@ -86,6 +92,12 @@ type AsyncAssertion interface { } // Assertions are returned by Ω and Expect and enable assertions against Gomega matchers +// +// The optional optionalDescription argument allows you to annotate the assertion with additional information. +// It is passed as the second argument and can be a format string followed by arguments, or a func() string. +// The description is included in failure messages to provide context. +// +// For details on annotating assertions, see: https://onsi.github.io/gomega/#annotating-assertions type Assertion interface { Should(matcher GomegaMatcher, optionalDescription ...any) bool ShouldNot(matcher GomegaMatcher, optionalDescription ...any) bool diff --git a/vendor/modules.txt b/vendor/modules.txt index e0f4ca237..b6887465f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -298,7 +298,7 @@ github.com/munnerz/goautoneg # github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f ## explicit github.com/mxk/go-flowrate/flowrate -# github.com/onsi/gomega v1.39.1 +# github.com/onsi/gomega v1.41.0 ## explicit; go 1.24.0 github.com/onsi/gomega github.com/onsi/gomega/format