diff --git a/go.mod b/go.mod index 31ba971a..de49fcfb 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/cloudfoundry/dropsonde v1.1.0 github.com/lib/pq v1.10.9 github.com/onsi/ginkgo/v2 v2.13.0 - github.com/onsi/gomega v1.29.0 + github.com/onsi/gomega v1.30.0 github.com/tedsuo/ifrit v0.0.0-20230330192023-5cba443a66c4 ) diff --git a/go.sum b/go.sum index 28b798fc..1994672c 100644 --- a/go.sum +++ b/go.sum @@ -168,8 +168,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= -github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= -github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= +github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= +github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/openzipkin/zipkin-go v0.4.1 h1:kNd/ST2yLLWhaWrkgchya40TJabe8Hioj9udfPcEO5A= github.com/openzipkin/zipkin-go v0.4.1/go.mod h1:qY0VqDSN1pOBN94dBc6w2GJlWLiovAyg7Qt6/I9HecM= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/vendor/github.com/onsi/gomega/CHANGELOG.md b/vendor/github.com/onsi/gomega/CHANGELOG.md index 4fc45f29..fe72a7b1 100644 --- a/vendor/github.com/onsi/gomega/CHANGELOG.md +++ b/vendor/github.com/onsi/gomega/CHANGELOG.md @@ -1,3 +1,12 @@ +## 1.30.0 + +### Features +- BeTrueBecause and BeFalseBecause allow for better failure messages [4da4c7f] + +### Maintenance +- Bump actions/checkout from 3 to 4 (#694) [6ca6e97] +- doc: fix type on gleak go doc [f1b8343] + ## 1.29.0 ### Features diff --git a/vendor/github.com/onsi/gomega/ghttp/handlers.go b/vendor/github.com/onsi/gomega/ghttp/handlers.go index fa7fc0ba..b2d1c2c4 100644 --- a/vendor/github.com/onsi/gomega/ghttp/handlers.go +++ b/vendor/github.com/onsi/gomega/ghttp/handlers.go @@ -28,8 +28,8 @@ func NewGHTTPWithGomega(gomega Gomega) *GHTTPWithGomega { } } -//CombineHandler takes variadic list of handlers and produces one handler -//that calls each handler in order. +// CombineHandler takes variadic list of handlers and produces one handler +// that calls each handler in order. func CombineHandlers(handlers ...http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { for _, handler := range handlers { @@ -38,11 +38,11 @@ func CombineHandlers(handlers ...http.HandlerFunc) http.HandlerFunc { } } -//VerifyRequest returns a handler that verifies that a request uses the specified method to connect to the specified path -//You may also pass in an optional rawQuery string which is tested against the request's `req.URL.RawQuery` +// VerifyRequest returns a handler that verifies that a request uses the specified method to connect to the specified path +// You may also pass in an optional rawQuery string which is tested against the request's `req.URL.RawQuery` // -//For path, you may pass in a string, in which case strict equality will be applied -//Alternatively you can pass in a matcher (ContainSubstring("/foo") and MatchRegexp("/foo/[a-f0-9]+") for example) +// For path, you may pass in a string, in which case strict equality will be applied +// Alternatively you can pass in a matcher (ContainSubstring("/foo") and MatchRegexp("/foo/[a-f0-9]+") for example) func (g GHTTPWithGomega) VerifyRequest(method string, path interface{}, rawQuery ...string) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { g.gomega.Expect(req.Method).Should(Equal(method), "Method mismatch") @@ -61,24 +61,24 @@ func (g GHTTPWithGomega) VerifyRequest(method string, path interface{}, rawQuery } } -//VerifyContentType returns a handler that verifies that a request has a Content-Type header set to the -//specified value +// VerifyContentType returns a handler that verifies that a request has a Content-Type header set to the +// specified value func (g GHTTPWithGomega) VerifyContentType(contentType string) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { g.gomega.Expect(req.Header.Get("Content-Type")).Should(Equal(contentType)) } } -//VerifyMimeType returns a handler that verifies that a request has a specified mime type set -//in Content-Type header +// VerifyMimeType returns a handler that verifies that a request has a specified mime type set +// in Content-Type header func (g GHTTPWithGomega) VerifyMimeType(mimeType string) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { g.gomega.Expect(strings.Split(req.Header.Get("Content-Type"), ";")[0]).Should(Equal(mimeType)) } } -//VerifyBasicAuth returns a handler that verifies the request contains a BasicAuth Authorization header -//matching the passed in username and password +// VerifyBasicAuth returns a handler that verifies the request contains a BasicAuth Authorization header +// matching the passed in username and password func (g GHTTPWithGomega) VerifyBasicAuth(username string, password string) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { auth := req.Header.Get("Authorization") @@ -91,11 +91,11 @@ func (g GHTTPWithGomega) VerifyBasicAuth(username string, password string) http. } } -//VerifyHeader returns a handler that verifies the request contains the passed in headers. -//The passed in header keys are first canonicalized via http.CanonicalHeaderKey. +// VerifyHeader returns a handler that verifies the request contains the passed in headers. +// The passed in header keys are first canonicalized via http.CanonicalHeaderKey. // -//The request must contain *all* the passed in headers, but it is allowed to have additional headers -//beyond the passed in set. +// The request must contain *all* the passed in headers, but it is allowed to have additional headers +// beyond the passed in set. func (g GHTTPWithGomega) VerifyHeader(header http.Header) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { for key, values := range header { @@ -105,9 +105,9 @@ func (g GHTTPWithGomega) VerifyHeader(header http.Header) http.HandlerFunc { } } -//VerifyHeaderKV returns a handler that verifies the request contains a header matching the passed in key and values -//(recall that a `http.Header` is a mapping from string (key) to []string (values)) -//It is a convenience wrapper around `VerifyHeader` that allows you to avoid having to create an `http.Header` object. +// VerifyHeaderKV returns a handler that verifies the request contains a header matching the passed in key and values +// (recall that a `http.Header` is a mapping from string (key) to []string (values)) +// It is a convenience wrapper around `VerifyHeader` that allows you to avoid having to create an `http.Header` object. func (g GHTTPWithGomega) VerifyHeaderKV(key string, values ...string) http.HandlerFunc { return g.VerifyHeader(http.Header{key: values}) } @@ -127,8 +127,8 @@ func (g GHTTPWithGomega) VerifyHost(host interface{}) http.HandlerFunc { } } -//VerifyBody returns a handler that verifies that the body of the request matches the passed in byte array. -//It does this using Equal(). +// VerifyBody returns a handler that verifies that the body of the request matches the passed in byte array. +// It does this using Equal(). func (g GHTTPWithGomega) VerifyBody(expectedBody []byte) http.HandlerFunc { return CombineHandlers( func(w http.ResponseWriter, req *http.Request) { @@ -140,10 +140,10 @@ func (g GHTTPWithGomega) VerifyBody(expectedBody []byte) http.HandlerFunc { ) } -//VerifyJSON returns a handler that verifies that the body of the request is a valid JSON representation -//matching the passed in JSON string. It does this using Gomega's MatchJSON method +// VerifyJSON returns a handler that verifies that the body of the request is a valid JSON representation +// matching the passed in JSON string. It does this using Gomega's MatchJSON method // -//VerifyJSON also verifies that the request's content type is application/json +// VerifyJSON also verifies that the request's content type is application/json func (g GHTTPWithGomega) VerifyJSON(expectedJSON string) http.HandlerFunc { return CombineHandlers( g.VerifyMimeType("application/json"), @@ -156,9 +156,9 @@ func (g GHTTPWithGomega) VerifyJSON(expectedJSON string) http.HandlerFunc { ) } -//VerifyJSONRepresenting is similar to VerifyJSON. Instead of taking a JSON string, however, it -//takes an arbitrary JSON-encodable object and verifies that the requests's body is a JSON representation -//that matches the object +// VerifyJSONRepresenting is similar to VerifyJSON. Instead of taking a JSON string, however, it +// takes an arbitrary JSON-encodable object and verifies that the requests's body is a JSON representation +// that matches the object func (g GHTTPWithGomega) VerifyJSONRepresenting(object interface{}) http.HandlerFunc { data, err := json.Marshal(object) g.gomega.Expect(err).ShouldNot(HaveOccurred()) @@ -168,10 +168,10 @@ func (g GHTTPWithGomega) VerifyJSONRepresenting(object interface{}) http.Handler ) } -//VerifyForm returns a handler that verifies a request contains the specified form values. +// VerifyForm returns a handler that verifies a request contains the specified form values. // -//The request must contain *all* of the specified values, but it is allowed to have additional -//form values beyond the passed in set. +// The request must contain *all* of the specified values, but it is allowed to have additional +// form values beyond the passed in set. func (g GHTTPWithGomega) VerifyForm(values url.Values) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { err := r.ParseForm() @@ -182,17 +182,17 @@ func (g GHTTPWithGomega) VerifyForm(values url.Values) http.HandlerFunc { } } -//VerifyFormKV returns a handler that verifies a request contains a form key with the specified values. +// VerifyFormKV returns a handler that verifies a request contains a form key with the specified values. // -//It is a convenience wrapper around `VerifyForm` that lets you avoid having to create a `url.Values` object. +// It is a convenience wrapper around `VerifyForm` that lets you avoid having to create a `url.Values` object. func (g GHTTPWithGomega) VerifyFormKV(key string, values ...string) http.HandlerFunc { return g.VerifyForm(url.Values{key: values}) } -//VerifyProtoRepresenting returns a handler that verifies that the body of the request is a valid protobuf -//representation of the passed message. +// VerifyProtoRepresenting returns a handler that verifies that the body of the request is a valid protobuf +// representation of the passed message. // -//VerifyProtoRepresenting also verifies that the request's content type is application/x-protobuf +// VerifyProtoRepresenting also verifies that the request's content type is application/x-protobuf func (g GHTTPWithGomega) VerifyProtoRepresenting(expected proto.Message) http.HandlerFunc { return CombineHandlers( g.VerifyContentType("application/x-protobuf"), @@ -205,7 +205,7 @@ func (g GHTTPWithGomega) VerifyProtoRepresenting(expected proto.Message) http.Ha actualValuePtr := reflect.New(expectedType.Elem()) actual, ok := actualValuePtr.Interface().(proto.Message) - g.gomega.Expect(ok).Should(BeTrue(), "Message value is not a proto.Message") + g.gomega.Expect(ok).Should(BeTrueBecause("Message value should be a proto.Message")) err = proto.Unmarshal(body, actual) g.gomega.Expect(err).ShouldNot(HaveOccurred(), "Failed to unmarshal protobuf") @@ -324,10 +324,10 @@ func (g GHTTPWithGomega) RespondWithJSONEncodedPtr(statusCode *int, object inter } } -//RespondWithProto returns a handler that responds to a request with the specified status code and a body -//containing the protobuf serialization of the provided message. +// RespondWithProto returns a handler that responds to a request with the specified status code and a body +// containing the protobuf serialization of the provided message. // -//Also, RespondWithProto can be given an optional http.Header. The headers defined therein will be added to the response headers. +// Also, RespondWithProto can be given an optional http.Header. The headers defined therein will be added to the response headers. func (g GHTTPWithGomega) RespondWithProto(statusCode int, message proto.Message, optionalHeader ...http.Header) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { data, err := proto.Marshal(message) diff --git a/vendor/github.com/onsi/gomega/gomega_dsl.go b/vendor/github.com/onsi/gomega/gomega_dsl.go index ba082146..c271a366 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.29.0" +const GOMEGA_VERSION = "1.30.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 cd3f431d..43f99437 100644 --- a/vendor/github.com/onsi/gomega/matchers.go +++ b/vendor/github.com/onsi/gomega/matchers.go @@ -1,6 +1,7 @@ package gomega import ( + "fmt" "time" "github.com/google/go-cmp/cmp" @@ -52,15 +53,31 @@ func BeNil() types.GomegaMatcher { } // BeTrue succeeds if actual is true +// +// In general, it's better to use `BeTrueBecause(reason)` to provide a more useful error message if a true check fails. func BeTrue() types.GomegaMatcher { return &matchers.BeTrueMatcher{} } // BeFalse succeeds if actual is false +// +// In general, it's better to use `BeFalseBecause(reason)` to provide a more useful error message if a false check fails. func BeFalse() types.GomegaMatcher { return &matchers.BeFalseMatcher{} } +// BeTrueBecause succeeds if actual is true and displays the provided reason if it is false +// fmt.Sprintf is used to render the reason +func BeTrueBecause(format string, args ...any) types.GomegaMatcher { + return &matchers.BeTrueMatcher{Reason: fmt.Sprintf(format, args...)} +} + +// BeFalseBecause succeeds if actual is false and displays the provided reason if it is true. +// fmt.Sprintf is used to render the reason +func BeFalseBecause(format string, args ...any) types.GomegaMatcher { + return &matchers.BeFalseMatcher{Reason: fmt.Sprintf(format, args...)} +} + // HaveOccurred succeeds if actual is a non-nil error // The typical Go error checking pattern looks like: // diff --git a/vendor/github.com/onsi/gomega/matchers/be_false_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_false_matcher.go index e326c015..8ee2b1c5 100644 --- a/vendor/github.com/onsi/gomega/matchers/be_false_matcher.go +++ b/vendor/github.com/onsi/gomega/matchers/be_false_matcher.go @@ -9,6 +9,7 @@ import ( ) type BeFalseMatcher struct { + Reason string } func (matcher *BeFalseMatcher) Match(actual interface{}) (success bool, err error) { @@ -20,9 +21,17 @@ func (matcher *BeFalseMatcher) Match(actual interface{}) (success bool, err erro } func (matcher *BeFalseMatcher) FailureMessage(actual interface{}) (message string) { - return format.Message(actual, "to be false") + if matcher.Reason == "" { + return format.Message(actual, "to be false") + } else { + return matcher.Reason + } } func (matcher *BeFalseMatcher) NegatedFailureMessage(actual interface{}) (message string) { - return format.Message(actual, "not to be false") + if matcher.Reason == "" { + return format.Message(actual, "not to be false") + } else { + return fmt.Sprintf(`Expected not false but got false\nNegation of "%s" failed`, matcher.Reason) + } } diff --git a/vendor/github.com/onsi/gomega/matchers/be_true_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_true_matcher.go index 60bc1e3f..3576aac8 100644 --- a/vendor/github.com/onsi/gomega/matchers/be_true_matcher.go +++ b/vendor/github.com/onsi/gomega/matchers/be_true_matcher.go @@ -9,6 +9,7 @@ import ( ) type BeTrueMatcher struct { + Reason string } func (matcher *BeTrueMatcher) Match(actual interface{}) (success bool, err error) { @@ -20,9 +21,17 @@ func (matcher *BeTrueMatcher) Match(actual interface{}) (success bool, err error } func (matcher *BeTrueMatcher) FailureMessage(actual interface{}) (message string) { - return format.Message(actual, "to be true") + if matcher.Reason == "" { + return format.Message(actual, "to be true") + } else { + return matcher.Reason + } } func (matcher *BeTrueMatcher) NegatedFailureMessage(actual interface{}) (message string) { - return format.Message(actual, "not to be true") + if matcher.Reason == "" { + return format.Message(actual, "not to be true") + } else { + return fmt.Sprintf(`Expected not true but got true\nNegation of "%s" failed`, matcher.Reason) + } } diff --git a/vendor/modules.txt b/vendor/modules.txt index d7d606e8..9265c5c5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -153,7 +153,7 @@ github.com/onsi/ginkgo/v2/internal/parallel_support github.com/onsi/ginkgo/v2/internal/testingtproxy github.com/onsi/ginkgo/v2/reporters github.com/onsi/ginkgo/v2/types -# github.com/onsi/gomega v1.29.0 +# github.com/onsi/gomega v1.30.0 ## explicit; go 1.18 github.com/onsi/gomega github.com/onsi/gomega/format