[common] Improve ShouldResembleProto to handle protos in structs.

A number of cases have arisen where tests want to compare
vanilla go structs with one or more nested proto messages. For
example, structs representing rows in Spanner with protocol buffer
fields.

Neither Goconvey's ShouldResemble or its replacement that
handles proto messages (ShouldResembleProto) can do equality
comparisons on these, leading to ad-hoc workarounds in tests or
direct calls into gocmp which are generally unsatisfactory from
a readability perspective.

Rather than implement a third ShouldResembleXXX method, this CL
modifies the comparison in the existing ShouldResembleProto method
to allow protos nested in other ways. The gocmp-comparison is
stricter than the existing ShouldResembleProto test as it verifies the
type of the enclosing slice (if any), so some tests must be updated.

Some CV tests were using ShouldResembleProto on go structs
with datastore keys and protos inside them, the old
ShouldResembleProto was performing no meaningful comparison in this
case due to a bug. Rather than delete this test, datastore key
equality was updated slightly to allow the test to pass.

BUG=None
TEST=SPANNER_EMULATOR=1 INTEGRATION_TESTS=1 go test
go.chromium.org/luci/...

Change-Id: I9424e58e0b1f693e9bebb3774996466bfce25f73
Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/luci-go/+/4749987
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Patrick Meiring <meiring@google.com>
Reviewed-by: Tuan Nguyen <nqmtuan@google.com>
25 files changed
tree: 6faba56c836775aefd0a2404c7fd08ac6f12db5a
  1. analysis/
  2. appengine/
  3. auth/
  4. auth_service/
  5. bisection/
  6. build/
  7. buildbucket/
  8. casviewer/
  9. cipd/
  10. cipkg/
  11. client/
  12. cmdrunner/
  13. common/
  14. config/
  15. config_service/
  16. cv/
  17. deploy/
  18. examples/
  19. gae/
  20. gce/
  21. grpc/
  22. hardcoded/
  23. led/
  24. logdog/
  25. luci_notify/
  26. lucicfg/
  27. lucictx/
  28. luciexe/
  29. mailer/
  30. milo/
  31. mmutex/
  32. provenance/
  33. resultdb/
  34. scheduler/
  35. scripts/
  36. server/
  37. standalone/
  38. starlark/
  39. swarming/
  40. third_party/
  41. tokenserver/
  42. tools/
  43. tree_status/
  44. vpython/
  45. web/
  46. .gitallowed
  47. .gitattributes
  48. .gitignore
  49. .golangci.yml
  50. AUTHORS
  51. codereview.settings
  52. CONTRIBUTING.md
  53. CONTRIBUTORS
  54. go.mod
  55. go.sum
  56. LICENSE
  57. OWNERS
  58. PRESUBMIT.py
  59. README.md
  60. tools.go
  61. WATCHLISTS
README.md

luci-go: LUCI services and tools in Go

GoReference

Installing

LUCI Go code is meant to be worked on from an Chromium infra.git checkout, which enforces packages versions and Go toolchain version. First get fetch via depot_tools.git then run:

fetch infra
cd infra/go
eval `./env.py`
cd src/go.chromium.org/luci

It is now possible to directly install tools with go install:

go install go.chromium.org/luci/auth/client/cmd/...@latest
go install go.chromium.org/luci/buildbucket/cmd/...@latest
go install go.chromium.org/luci/cipd/client/cmd/...@latest
go install go.chromium.org/luci/client/cmd/...@latest
go install go.chromium.org/luci/cv/cmd/...@latest
go install go.chromium.org/luci/gce/cmd/...@latest
go install go.chromium.org/luci/grpc/cmd/...@latest
go install go.chromium.org/luci/logdog/client/cmd/...@latest
go install go.chromium.org/luci/luci_notify/cmd/...@latest
go install go.chromium.org/luci/lucicfg/cmd/...@latest
go install go.chromium.org/luci/luciexe/legacy/cmd/...@latest
go install go.chromium.org/luci/mailer/cmd/...@latest
go install go.chromium.org/luci/mmutex/cmd/...@latest
go install go.chromium.org/luci/resultdb/cmd/...@latest
go install go.chromium.org/luci/server/cmd/...@latest
go install go.chromium.org/luci/swarming/cmd/...@latest
go install go.chromium.org/luci/tokenserver/cmd/...@latest
go install go.chromium.org/luci/tools/cmd/...@latest

Contributing

Contributing uses the same flow as Chromium contributions.