Fix cmp.Diff argument order in tests

This commit is contained in:
Joël Stemmer
2022-05-07 12:59:39 +01:00
parent 7c195be87f
commit df7394c77c
4 changed files with 16 additions and 15 deletions

View File

@ -44,13 +44,13 @@ func TestCreateFromReport(t *testing.T) {
}
got := CreateFromReport(report, "")
if diff := cmp.Diff(got, want); diff != "" {
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("CreateFromReport incorrect, diff (-want, +got):\n%s\n", diff)
}
}
func TestMarshalUnmarshal(t *testing.T) {
suites := Testsuites{
want := Testsuites{
Name: "name",
Time: "12.345",
Tests: 1,
@ -89,18 +89,18 @@ func TestMarshalUnmarshal(t *testing.T) {
},
}
data, err := xml.MarshalIndent(suites, "", "\t")
data, err := xml.MarshalIndent(want, "", "\t")
if err != nil {
t.Fatal(err)
}
var unmarshaled Testsuites
if err := xml.Unmarshal(data, &unmarshaled); err != nil {
var got Testsuites
if err := xml.Unmarshal(data, &got); err != nil {
t.Fatal(err)
}
suites.XMLName.Local = "testsuites"
if diff := cmp.Diff(suites, unmarshaled); diff != "" {
want.XMLName.Local = "testsuites"
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("Unmarshal result incorrect, diff (-want +got):\n%s\n", diff)
}
}
@ -152,7 +152,7 @@ func TestGroupBenchmarksByName(t *testing.T) {
for _, test := range tests {
got := groupBenchmarksByName(test.in)
if diff := cmp.Diff(got, test.want); diff != "" {
if diff := cmp.Diff(test.want, got); diff != "" {
t.Errorf("groupBenchmarksByName result incorrect, diff (-want, +got):\n%s\n", diff)
}
}