Tests: Use DeepEqual replacement using go-cmp, which is more flexible#13452
Tests: Use DeepEqual replacement using go-cmp, which is more flexible#13452bboreham merged 6 commits intoprometheus:mainfrom
Conversation
cstyan
left a comment
There was a problem hiding this comment.
remote pkg changes lgtm
should we consider a follow up to change all usages of require.Equal, just so we don't end up with inconsistent usage throughout the repo?
A couple of reasons why I didn't do that already:
I'm interested to hear what anyone else thinks. |
Yep, was just thinking about it as a follow up not in this PR. Your third point is a compelling one for not doing so though. But my question then would be how we can document and make recommendations about when the testutil comparison should be used over deep equal. |
09ccb11 to
a75f959
Compare
go-cmp allows control over how unexported fields and implementation details are handled. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Use DeepEqual replacement using go-cmp, which is more flexible. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
go-cmp allows more control over unexported fields and implementation details. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Normally, a NaN value is never equal to any other value. Compare sample values via `Float64bits` so that NaN values which are exactly the same will compare equal. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Also one simpler call checking nil. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
go-cmpallows control over how unexported fields and implementation details are handled.Make use of this flexibility to remove convoluted work-arounds for comparing NaNs.
This is excerpted from #12304, where an implementation detail of
labels.LabelsmakesDeepEqualunhelpful.I though it is valid as a stand-alone change, and makes #12304 easier to review.
I did not change every use of
require.Equalto use this new implementation, only those impacted by #12304.