From 168df6a82c9cf977e0e591ed9dbb0682627424ab Mon Sep 17 00:00:00 2001 From: Sarah French Date: Fri, 10 Jan 2025 19:09:20 +0000 Subject: [PATCH] Refactor comparison of byte slices --- internal/command/artifact/junit_test.go | 2 +- internal/command/test_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/command/artifact/junit_test.go b/internal/command/artifact/junit_test.go index 5890d2e20d04..e38e92653e60 100644 --- a/internal/command/artifact/junit_test.go +++ b/internal/command/artifact/junit_test.go @@ -60,7 +60,7 @@ func TestJUnitXMLFile_save(t *testing.T) { t.Fatalf("unexpected error opening file") } - if bytes.Compare(fileContent, xml) != 0 { + if !bytes.Equal(fileContent, xml) { t.Fatalf("wanted XML:\n%s\n got XML:\n%s\n", string(xml), string(fileContent)) } }) diff --git a/internal/command/test_test.go b/internal/command/test_test.go index aa14e837b0ac..f1365c100e77 100644 --- a/internal/command/test_test.go +++ b/internal/command/test_test.go @@ -2405,7 +2405,7 @@ func TestTest_JUnitOutput(t *testing.T) { timestampRegexp := regexp.MustCompile(`timestamp="[^"]+"`) actualOut = timestampRegexp.ReplaceAll(actualOut, []byte("timestamp=\"TIMESTAMP_REDACTED\"")) - if bytes.Compare(actualOut, expectedOutput) != 0 { + if !bytes.Equal(actualOut, expectedOutput) { t.Fatalf("wanted XML:\n%s\n got XML:\n%s\n", string(expectedOutput), string(actualOut)) }