Open antoniomacri opened 2 years ago
Hey Antonio, note that you can define your own ShouldResembleProto and use that with GoConvey. That's exactly what the Chrome infrastructure team has done, as they're big users of GoConvey and of Protocol Buffers. I'd be curious for @riannucci to chime in, but it might be weird for GoConvey to pull in the protobuf repo as a dependency to make this natively supported.
Have a look at these: definition of ShouldResembleProto: https://chromium.googlesource.com/infra/luci/luci-go/+/3809e3303d0b/common/testing/assertions/proto_tests.go#37 example usage of that function: https://chromium.googlesource.com/infra/luci/luci-go/+/3809e3303d0b/auth_service/impl/servers/accounts/server_test.go#43
Comparison of proto Messages performed using
ShouldResemble
is unreliable.Consider this code:
The call to
Printf
causesx.String()
to be called. This in turn initializes thestate
and itsatomicMessageInfo
field on the proto message. Thereforex
has theatomicMessageInfo
set, whiley
doesn't. This causesreflect.DeepEqual
to return false.Another problem stems from the rendering of the diff (#660).
Could a
ShouldResembleProto
be added for expliciting comparing proto messages? It should callproto.Equal
.