-
Notifications
You must be signed in to change notification settings - Fork 703
internal/assert: Better protobuf diffs by aliasing testify/assert #2787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7b09f74 to
c82153a
Compare
Codecov Report
@@ Coverage Diff @@
## master #2787 +/- ##
==========================================
- Coverage 76.69% 76.64% -0.05%
==========================================
Files 72 72
Lines 5651 5635 -16
==========================================
- Hits 4334 4319 -15
Misses 1228 1228
+ Partials 89 88 -1
|
b4974b3 to
317ded9
Compare
internal/assert/assert.go
Outdated
| "github.com/golang/protobuf/ptypes/any" | ||
| "github.com/google/go-cmp/cmp" | ||
| "github.com/google/go-cmp/cmp/cmpopts" | ||
| tassert "github.com/stretchr/testify/require" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be testify/assert so that testing.Error is used.
d8b28e2 to
448d364
Compare
skriss
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly LGTM, one comment.
|
Okay, this is good for rereview now. |
jpeach
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
618ca22 to
e60cfad
Compare
This change replaces the current `github.com/google/go-cmp/cmp` based internal `assert.Equal` with an aliased version of testify `assert.Equal`. If we need other assertions, we'll need to add them one by one. This allows better output for non-protobuf tests. However, it does mean that now Error message text is being checked - there were about four places I needed to fix as a result. Unfortunately, testify does not have support for unmarshaling protobufs, so I needed to move to a new `assert.EqualProto` function that uses `protocmp` to compare the two protobufs. This also exposed another issue that the old `assert.Equal` was working around: the Envoy DiscoveryResponse proto has version and nonce fields that can change in ways that make tests flaky. However, it turns out that all the tests in `featuretests` that needed the workaround only change the `Resources` field. So I've updated the featuretests infrastructure to have the `Equals` method on the Response struct for testing only compare that `Resources` field. This should probably be replaced with `EqualResources` and `NoResources` for the normal and empty case respectively, but this PR is big enough for now. Updates projectcontour#2786 for now, until a second PR that will change the names as above. Signed-off-by: Nick Young <[email protected]>
Signed-off-by: Nick Young <[email protected]>
Signed-off-by: Nick Young <[email protected]>
…ert more The `internal/assert` library will now behave the same as the testify `assert`: failures will produce t.Error() output, but will not be fatal. The feature tests have been updated so that the `Equals()` method is still fatal; this replicates the existing behavior. Signed-off-by: Nick Young <[email protected]>
Signed-off-by: Nick Young <[email protected]>
e60cfad to
c8ce726
Compare
This change replaces the current
github.com/google/go-cmp/cmpbased internalassert.Equalwith an aliased version of testifyassert.Equal. If we needother assertions, we'll need to add them one by one. This allows better output
for non-protobuf tests. However, it does mean that now Error message text is
being checked - there were about four places I needed to fix as a result.
Unfortunately, testify does not have support for unmarshaling protobufs, so
I needed to move to a new
assert.EqualProtofunction that usesprotocmpto compare the two protobufs.
This also exposed another issue that the old
assert.Equalwas working around:the Envoy DiscoveryResponse proto has version and nonce fields that can change in
ways that make tests flaky. However, it turns out that all the tests in
featureteststhat needed the workaround only change the
Resourcesfield. So I've updated thefeaturetests infrastructure to have the
Equalsmethod on the Response structfor testing only compare that
Resourcesfield. This should probably be replacedwith
EqualResourcesandNoResourcesfor the normal and empty case respectively,but this PR is big enough for now.
Updates #2786 for now, until a second PR that will change the names as above.
Signed-off-by: Nick Young [email protected]