-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make cmp.Diff want vs got usage clear 🚰
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 at https://godoc.org/github.com/google/go-cmp/cmp#Diff passes these arguments as `cmp.Diff(want, got)`. If we reverse them, which many of our tests did, the results are counter intuitive: the "extra" stuff gets a `-` and the missing stuff gets a `+`. It seems like a small thing but it'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: - Makes them consistently pass `(want, got)` - Annotates the failure message with a legend for `-` and `+` - Adds more details to the messages when applicable so you know what the diff is that you're looking at
- Loading branch information
1 parent
6c132b9
commit 3bf48cf
Showing
4 changed files
with
37 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters