diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f351dd..d1e0ef6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,9 +79,9 @@ jobs: go-version: '1.25.3' - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v7 with: - version: v2.6.0 + version: latest args: --timeout=5m build: diff --git a/services/gateway/gateway_test.go b/services/gateway/gateway_test.go index 48a5c8e..ac9c1ff 100644 --- a/services/gateway/gateway_test.go +++ b/services/gateway/gateway_test.go @@ -6,6 +6,7 @@ import ( "errors" "net/http" "net/http/httptest" + "os" "testing" "time" @@ -18,11 +19,17 @@ import ( "github.com/stretchr/testify/require" ) +// TestMain sets up the test environment before running tests. +func TestMain(m *testing.M) { + // Set Gin to test mode once for all tests to avoid race conditions + gin.SetMode(gin.TestMode) + // Run tests + os.Exit(m.Run()) +} + func TestNewGateway(t *testing.T) { t.Parallel() - gin.SetMode(gin.TestMode) - tests := []struct { name string cfg config.ConfigProvider @@ -70,8 +77,6 @@ func TestNewGateway(t *testing.T) { func TestGateway_SetupRoutes(t *testing.T) { t.Parallel() - gin.SetMode(gin.TestMode) - tests := []struct { name string routes []RouteConfig @@ -127,8 +132,6 @@ func TestGateway_SetupRoutes(t *testing.T) { func TestGateway_handleRoute(t *testing.T) { t.Parallel() - gin.SetMode(gin.TestMode) - tests := []struct { name string route RouteConfig @@ -199,8 +202,6 @@ func TestGateway_handleRoute(t *testing.T) { func TestGateway_handleRoute_AllMethods(t *testing.T) { t.Parallel() - gin.SetMode(gin.TestMode) - methods := []string{ http.MethodGet, http.MethodPost, @@ -271,8 +272,6 @@ func TestLoadRoutes(t *testing.T) { func TestGateway_NoRoute(t *testing.T) { t.Parallel() - gin.SetMode(gin.TestMode) - gateway := &Gateway{ config: &mockConfigProvider{}, log: &mockLogger{},