Skip to content
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

Make cmp.Diff want vs got usage clear 🚰 #1480

Merged

Commits on Oct 25, 2019

  1. Make cmp.Diff want vs got usage clear 🚰

    While working on tektoncd#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 tektoncd#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
    bobcatfish committed Oct 25, 2019
    Configuration menu
    Copy the full SHA
    e51ddca View commit details
    Browse the repository at this point in the history