From 125573d6fc0db2dd0aeac6a0c45ff12aed5e96d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Stemmer?= Date: Thu, 31 Mar 2022 23:08:54 +0100 Subject: [PATCH] Fix incorrect diff error messages in tests --- go-junit-report_test.go | 2 +- pkg/parser/gotest/gotest_test.go | 4 ++-- pkg/parser/gotest/json_test.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go-junit-report_test.go b/go-junit-report_test.go index ed4be99..f783eee 100644 --- a/go-junit-report_test.go +++ b/go-junit-report_test.go @@ -102,7 +102,7 @@ func testRun(inputFile, reportFile string, config TestConfig, t *testing.T) { } if diff := cmp.Diff(output.String(), string(wantReport)); diff != "" { - t.Errorf("Unexpected report diff (-got, +want):\n%v", diff) + t.Errorf("Unexpected report diff (-want, +got):\n%v", diff) } } diff --git a/pkg/parser/gotest/gotest_test.go b/pkg/parser/gotest/gotest_test.go index e1ee75f..3cdd684 100644 --- a/pkg/parser/gotest/gotest_test.go +++ b/pkg/parser/gotest/gotest_test.go @@ -208,7 +208,7 @@ func TestParseLine(t *testing.T) { parser.parseLine(test.input) got := parser.events if diff := cmp.Diff(got, want); diff != "" { - t.Errorf("parseLine(%q) returned unexpected events, diff (-got, +want):\n%v", test.input, diff) + t.Errorf("parseLine(%q) returned unexpected events, diff (-want, +got):\n%v", test.input, diff) } }) } @@ -310,6 +310,6 @@ func TestReport(t *testing.T) { parser := New(TimestampFunc(func() time.Time { return testTimestamp })) actual := parser.report(events) if diff := cmp.Diff(actual, expected); diff != "" { - t.Errorf("FromEvents report incorrect, diff (-got, +want):\n%v", diff) + t.Errorf("FromEvents report incorrect, diff (-want, +got):\n%v", diff) } } diff --git a/pkg/parser/gotest/json_test.go b/pkg/parser/gotest/json_test.go index 1be9068..915a2bd 100644 --- a/pkg/parser/gotest/json_test.go +++ b/pkg/parser/gotest/json_test.go @@ -25,7 +25,7 @@ func TestJSONReaderReadAll(t *testing.T) { ` if diff := cmp.Diff(string(got), want); diff != "" { - t.Errorf("unexpected result from jsonReader, diff (-got, +want):\n%s\n", diff) + t.Errorf("unexpected result from jsonReader, diff (-want, +got):\n%s\n", diff) } } @@ -52,12 +52,12 @@ func TestJSONReaderReadSmallBuffer(t *testing.T) { } if diff := cmp.Diff(string(buf[:n]), string(want)); diff != "" { - t.Fatalf("unexpected result from jsonReader, diff (-got, +want):\n%s\n", diff) + t.Fatalf("unexpected result from jsonReader, diff (-want, +got):\n%s\n", diff) } } _, err := r.Read(buf) if err != io.EOF { - t.Fatalf("unexpected result from jsonReader: got %v, want %v", err, io.EOF) + t.Fatalf("unexpected error from jsonReader: got %v, want %v", err, io.EOF) } }