From 503acff97580aa803f5d639fb1fbb06ad1226c31 Mon Sep 17 00:00:00 2001 From: kimsm28 Date: Thu, 2 Jul 2026 21:57:38 +0900 Subject: [PATCH] fix(registry): resolve golangci-lint issues in token-auth tests - Use (*net.ListenConfig).Listen with the test context instead of net.Listen (noctx). - Use suite.NoError instead of suite.Nil for the error check (testifylint). - Drop the unnecessary leading blank lines in the scope test funcs (whitespace). Co-Authored-By: Claude Opus 4.8 (1M context) Signed-off-by: kimsm28 --- pkg/registry/client_scope_test.go | 8 ++++---- pkg/registry/registry_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/registry/client_scope_test.go b/pkg/registry/client_scope_test.go index 98cdc74ff..f5f32ecb1 100644 --- a/pkg/registry/client_scope_test.go +++ b/pkg/registry/client_scope_test.go @@ -46,7 +46,6 @@ func (suite *RegistryScopeTestSuite) TearDownSuite() { } func (suite *RegistryScopeTestSuite) Test_1_Check_Push_Request_Scope() { - requestURL := make(chan string, 1) handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Capture only the first auth request; never block the handler if the @@ -58,7 +57,8 @@ func (suite *RegistryScopeTestSuite) Test_1_Check_Push_Request_Scope() { } w.WriteHeader(http.StatusOK) }) - listener, err := net.Listen("tcp", suite.AuthServerHost) + lnCfg := net.ListenConfig{} + listener, err := lnCfg.Listen(suite.T().Context(), "tcp", suite.AuthServerHost) suite.NoError(err, "no error creating server listener") ts := httptest.NewUnstartedServer(handler) @@ -92,7 +92,6 @@ func (suite *RegistryScopeTestSuite) Test_1_Check_Push_Request_Scope() { } func (suite *RegistryScopeTestSuite) Test_2_Check_Pull_Request_Scope() { - requestURL := make(chan string, 1) handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Capture only the first auth request; never block the handler if the @@ -104,7 +103,8 @@ func (suite *RegistryScopeTestSuite) Test_2_Check_Pull_Request_Scope() { } w.WriteHeader(http.StatusOK) }) - listener, err := net.Listen("tcp", suite.AuthServerHost) + lnCfg := net.ListenConfig{} + listener, err := lnCfg.Listen(suite.T().Context(), "tcp", suite.AuthServerHost) suite.NoError(err, "no error creating server listener") ts := httptest.NewUnstartedServer(handler) diff --git a/pkg/registry/registry_test.go b/pkg/registry/registry_test.go index d00a9f3c6..9388c8142 100644 --- a/pkg/registry/registry_test.go +++ b/pkg/registry/registry_test.go @@ -147,8 +147,8 @@ func setup(suite *TestRegistry, tlsEnabled, insecure bool, auth string) { config.Storage = map[string]configuration.Parameters{"inmemory": map[string]any{}} if auth == "token" { - ln, err := net.Listen("tcp", "127.0.0.1:0") - suite.Nil(err, "no error finding free port for test auth server") + ln, err := lnCfg.Listen(suite.T().Context(), "tcp", "127.0.0.1:0") + suite.NoError(err, "no error finding free port for test auth server") defer ln.Close() //set test auth server host