@@ -16,6 +16,8 @@ import (
1616 "github.com/onsi/gomega/internal/gutil"
1717 "github.com/onsi/gomega/types"
1818 "google.golang.org/protobuf/proto"
19+ "google.golang.org/protobuf/protoadapt"
20+ "google.golang.org/protobuf/runtime/protoiface"
1921)
2022
2123type GHTTPWithGomega struct {
@@ -193,7 +195,7 @@ func (g GHTTPWithGomega) VerifyFormKV(key string, values ...string) http.Handler
193195// representation of the passed message.
194196//
195197// VerifyProtoRepresenting also verifies that the request's content type is application/x-protobuf
196- func (g GHTTPWithGomega ) VerifyProtoRepresenting (expected proto. Message ) http.HandlerFunc {
198+ func (g GHTTPWithGomega ) VerifyProtoRepresenting (expected protoiface. MessageV1 ) http.HandlerFunc {
197199 return CombineHandlers (
198200 g .VerifyContentType ("application/x-protobuf" ),
199201 func (w http.ResponseWriter , req * http.Request ) {
@@ -204,13 +206,14 @@ func (g GHTTPWithGomega) VerifyProtoRepresenting(expected proto.Message) http.Ha
204206 expectedType := reflect .TypeOf (expected )
205207 actualValuePtr := reflect .New (expectedType .Elem ())
206208
207- actual , ok := actualValuePtr .Interface ().(proto. Message )
208- g .gomega .Expect (ok ).Should (BeTrueBecause ("Message value should be a proto.Message " ))
209+ actual , ok := actualValuePtr .Interface ().(protoiface. MessageV1 )
210+ g .gomega .Expect (ok ).Should (BeTrueBecause ("Message value should be a protoiface.MessageV1 " ))
209211
210- err = proto .Unmarshal (body , actual )
212+ err = proto .Unmarshal (body , protoadapt . MessageV2Of ( actual ) )
211213 g .gomega .Expect (err ).ShouldNot (HaveOccurred (), "Failed to unmarshal protobuf" )
212214
213- g .gomega .Expect (proto .Equal (expected , actual )).Should (BeTrue (), "ProtoBuf Mismatch" )
215+ g .gomega .Expect (proto .Equal (protoadapt .MessageV2Of (expected ), protoadapt .MessageV2Of (actual ))).
216+ Should (BeTrue (), "ProtoBuf Mismatch" )
214217 },
215218 )
216219}
@@ -328,9 +331,9 @@ func (g GHTTPWithGomega) RespondWithJSONEncodedPtr(statusCode *int, object inter
328331// containing the protobuf serialization of the provided message.
329332//
330333// Also, RespondWithProto can be given an optional http.Header. The headers defined therein will be added to the response headers.
331- func (g GHTTPWithGomega ) RespondWithProto (statusCode int , message proto. Message , optionalHeader ... http.Header ) http.HandlerFunc {
334+ func (g GHTTPWithGomega ) RespondWithProto (statusCode int , message protoadapt. MessageV1 , optionalHeader ... http.Header ) http.HandlerFunc {
332335 return func (w http.ResponseWriter , req * http.Request ) {
333- data , err := proto .Marshal (message )
336+ data , err := proto .Marshal (protoadapt . MessageV2Of ( message ) )
334337 g .gomega .Expect (err ).ShouldNot (HaveOccurred ())
335338
336339 var headers http.Header
@@ -397,7 +400,7 @@ func VerifyFormKV(key string, values ...string) http.HandlerFunc {
397400 return NewGHTTPWithGomega (gomega .Default ).VerifyFormKV (key , values ... )
398401}
399402
400- func VerifyProtoRepresenting (expected proto. Message ) http.HandlerFunc {
403+ func VerifyProtoRepresenting (expected protoiface. MessageV1 ) http.HandlerFunc {
401404 return NewGHTTPWithGomega (gomega .Default ).VerifyProtoRepresenting (expected )
402405}
403406
@@ -417,6 +420,6 @@ func RespondWithJSONEncodedPtr(statusCode *int, object interface{}, optionalHead
417420 return NewGHTTPWithGomega (gomega .Default ).RespondWithJSONEncodedPtr (statusCode , object , optionalHeader ... )
418421}
419422
420- func RespondWithProto (statusCode int , message proto. Message , optionalHeader ... http.Header ) http.HandlerFunc {
423+ func RespondWithProto (statusCode int , message protoadapt. MessageV1 , optionalHeader ... http.Header ) http.HandlerFunc {
421424 return NewGHTTPWithGomega (gomega .Default ).RespondWithProto (statusCode , message , optionalHeader ... )
422425}
0 commit comments