Skip to content

Commit 70f603f

Browse files
authored
test: place the want in the first argument of cmp.Diff() (#2260)
The error message becomes correct if we put the "want" in the first argument of cmp.Diff() function. See code snippet in https://pkg.go.dev/github.com/google/go-cmp/cmp#Diff ``` if diff := cmp.Diff(want, got); diff != "" { t.Errorf("MakeGatewayInfo() mismatch (-want +got):\n%s", diff) ```
1 parent f12f284 commit 70f603f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

internal/librarian/release_init_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ func TestInitRun(t *testing.T) {
10651065
// we expect this to be 1. Otherwise, the dockerInitCalls should be 0. Run this check even
10661066
// if there is an error that is wanted to ensure that a docker request is only made when
10671067
// we want it to.
1068-
if diff := cmp.Diff(test.containerClient.initCalls, test.dockerInitCalls); diff != "" {
1068+
if diff := cmp.Diff(test.dockerInitCalls, test.containerClient.initCalls); diff != "" {
10691069
t.Errorf("docker init calls mismatch (-want +got):\n%s", diff)
10701070
}
10711071

internal/sidekick/internal/parser/routing_info_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func TestExamples(t *testing.T) {
248248
if !ok {
249249
t.Fatalf("Cannot find method %s in API State", test.methodID)
250250
}
251-
if diff := cmp.Diff(got.Routing, test.want); diff != "" {
251+
if diff := cmp.Diff(test.want, got.Routing); diff != "" {
252252
t.Errorf("mismatch (-want, +got):\n%s", diff)
253253
}
254254
})
@@ -527,7 +527,7 @@ func TestParseRoutingPathSpecSuccess(t *testing.T) {
527527
} {
528528
t.Run(test.path, func(t *testing.T) {
529529
got, width := parseRoutingPathSpec(test.path)
530-
if diff := cmp.Diff(got.Segments, test.wantSegments); diff != "" {
530+
if diff := cmp.Diff(test.wantSegments, got.Segments); diff != "" {
531531
t.Errorf("mismatch (-want, +got):\n%s\n", diff)
532532
}
533533
if test.path[width:] != test.wantTrailer {

0 commit comments

Comments
 (0)