diff options
| author | Jonathan Amsterdam <jba@google.com> | 2020-09-02 13:26:26 -0400 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2020-09-02 18:50:20 +0000 |
| commit | 580f0e7b9f9ee550c5e0f388aa4904aa550e146c (patch) | |
| tree | 55bbb448f5ca6d258b15b75d87c9254d0a15170e /internal/queue/queue_test.go | |
| parent | 6d50f4f89b697ebb4e610d94ae53ef8443745aae (diff) | |
| download | go-x-pkgsite-580f0e7b9f9ee550c5e0f388aa4904aa550e146c.tar.xz | |
internal/queue: compare protos with proto.Equal
We were calling cmp.Diff on protobuf messages directly, which is not a
good idea. Use proto.Equal instead. Since it doesn't play nicely with
the IgnoreFields option, ignore the Name field in a different way.
Change-Id: Ie0dfa82b2b78c40402d2a05fed9f4dceff2fc2bf
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/252777
Reviewed-by: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'internal/queue/queue_test.go')
| -rw-r--r-- | internal/queue/queue_test.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/internal/queue/queue_test.go b/internal/queue/queue_test.go index ddd810c8..067fa090 100644 --- a/internal/queue/queue_test.go +++ b/internal/queue/queue_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" + proto "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "golang.org/x/pkgsite/internal/config" taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2" ) @@ -88,7 +88,8 @@ func TestNewTaskRequest(t *testing.T) { t.Fatal(err) } got := gcp.newTaskRequest("mod", "v1.2.3", "suf", time.Minute) - if diff := cmp.Diff(test.want, got, cmpopts.IgnoreFields(taskspb.Task{}, "Name")); diff != "" { + test.want.Task.Name = got.Task.Name + if diff := cmp.Diff(test.want, got, cmp.Comparer(proto.Equal)); diff != "" { t.Errorf("mismatch (-want, +got):\n%s", diff) } }) |
