From 364d3a0ac905613297314c11b395962b18d0377d Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 27 Mar 2024 08:10:40 -0700 Subject: [PATCH] fix: new staticheck and linter issues reported (#19340) --- cmd/data-usage_test.go | 1 + cmd/erasure-healing_test.go | 4 ++-- internal/http/server_test.go | 9 +-------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/cmd/data-usage_test.go b/cmd/data-usage_test.go index b8b5a9a7c..bd39437ed 100644 --- a/cmd/data-usage_test.go +++ b/cmd/data-usage_test.go @@ -364,6 +364,7 @@ func TestDataUsageUpdatePrefix(t *testing.T) { } if e == nil { t.Fatal("got nil result") + return } if e.Size != int64(w.size) { t.Error("got size", e.Size, "want", w.size) diff --git a/cmd/erasure-healing_test.go b/cmd/erasure-healing_test.go index 9759e01c6..3e8fcfd6d 100644 --- a/cmd/erasure-healing_test.go +++ b/cmd/erasure-healing_test.go @@ -634,7 +634,7 @@ func TestHealingDanglingObject(t *testing.T) { defer removeRoots(fsDirs) // Everything is fine, should return nil - objLayer, disks, err := initObjectLayer(ctx, mustGetPoolEndpoints(0, fsDirs...)) + objLayer, _, err := initObjectLayer(ctx, mustGetPoolEndpoints(0, fsDirs...)) if err != nil { t.Fatal(err) } @@ -650,7 +650,7 @@ func TestHealingDanglingObject(t *testing.T) { t.Fatalf("Failed to make a bucket - %v", err) } - disks = objLayer.(*erasureServerPools).serverPools[0].erasureDisks[0] + disks := objLayer.(*erasureServerPools).serverPools[0].erasureDisks[0] orgDisks := append([]StorageAPI{}, disks...) // Enable versioning. diff --git a/internal/http/server_test.go b/internal/http/server_test.go index c9cc7012a..9ace90e49 100644 --- a/internal/http/server_test.go +++ b/internal/http/server_test.go @@ -58,17 +58,10 @@ func TestNewServer(t *testing.T) { } if server == nil { t.Fatalf("Case %v: server: expected: , got: ", (i + 1)) - } - - if !reflect.DeepEqual(server.Addrs, testCase.addrs) { + } else if !reflect.DeepEqual(server.Addrs, testCase.addrs) { t.Fatalf("Case %v: server.Addrs: expected: %v, got: %v", (i + 1), testCase.addrs, server.Addrs) } - // Interfaces are not comparable even with reflection. - // if !reflect.DeepEqual(server.Handler, testCase.handler) { - // t.Fatalf("Case %v: server.Handler: expected: %v, got: %v", (i + 1), testCase.handler, server.Handler) - // } - if testCase.certFn == nil { if server.TLSConfig != nil { t.Fatalf("Case %v: server.TLSConfig: expected: , got: %v", (i + 1), server.TLSConfig)