if both types are proto messages, use proto.Equal #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
golang/protobuf 1.0.0 contained a few major changes, one of which was the addition of a new field:
As noted, the presence of these new fields breaks test assertions.
Description
This PR modifies the behavior for
ObjectsAreEqual
which is used by assertion methods likeassert.Equal
to support equality checks for protobuf messages.This allows us to transparently compare protobufs messages without breaking existing tests even if they have different underlying
XXX_
values. This is recommended by the protobuf team.The alternative is create another assertion method specific to protobuf, then migrate every existing assertions that compares two protobuf messages to use the new assertion method. Even then, it does not cover cases like slices or maps that may contain protobuf messages. I think forking the assertion library is the most straight-forward solution with relative low-cost, as this is a relatively simple library, it should be easy to keep the forks in sync.
Also, I don't think it's likely that this will be accepted upstream as it would introduce the protobuf dependency to all users even thought they may not be using protobuf. I might try to suggest using a compiler flag upstream to make this functionality optional, but I don't think it should block our own upgrades.
Testing