Make cmp.Diff want vs got usage clear 🚰 #1480
Merged
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.
Changes
While working on #1417 (which we decided not to go ahead with) I made a
lot of unit tests fail. B/c I was changing how steps were added (for
the volume resource) these failures were often in the middle of big
diffs. It turns out we were inconsistent about how we used cmp.Diff:
anything that is in the first argument but not in the second gets a
-
before it, anything that is in the second argument but not in the first
gets a
+
, which is why the example athttps://godoc.org/github.com/google/go-cmp/cmp#Diff passes these
arguments as
cmp.Diff(want, got)
. If we reverse them, which many ofour tests did, the results are counter intuitive: the "extra" stuff gets
a
-
and the missing stuff gets a+
. It seems like a small thing butit's really hard to wrap your head around! So this commit takes a bunch
of these tests (not all of them, just the ones I was touchin in #1417)
and:
(want, got)
-
and+
diff is that you're looking at
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Double check this list of stuff that's easy to miss:
cmd
dir, please updatethe release Task to build and release this image.
Reviewer Notes
If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.