From b8a1c4a7f78a3c3a0b7dedddb5fb990c60f0ecd3 Mon Sep 17 00:00:00 2001 From: Tiago Peczenyj Date: Thu, 5 Oct 2023 10:33:13 +0200 Subject: [PATCH 1/2] fix loop variable xxx captured by func literal --- middleware/compress/compress_test.go | 1 + middleware/filesystem/filesystem_test.go | 1 + middleware/pprof/pprof_test.go | 2 ++ 3 files changed, 4 insertions(+) diff --git a/middleware/compress/compress_test.go b/middleware/compress/compress_test.go index 4baf19c73d..2c5c52d8a8 100644 --- a/middleware/compress/compress_test.go +++ b/middleware/compress/compress_test.go @@ -53,6 +53,7 @@ func Test_Compress_Different_Level(t *testing.T) { t.Parallel() levels := []Level{LevelBestSpeed, LevelBestCompression} for _, level := range levels { + level := level t.Run(fmt.Sprintf("level %d", level), func(t *testing.T) { t.Parallel() app := fiber.New() diff --git a/middleware/filesystem/filesystem_test.go b/middleware/filesystem/filesystem_test.go index d592046c45..4c646fdd90 100644 --- a/middleware/filesystem/filesystem_test.go +++ b/middleware/filesystem/filesystem_test.go @@ -119,6 +119,7 @@ func Test_FileSystem(t *testing.T) { } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, tt.url, nil)) diff --git a/middleware/pprof/pprof_test.go b/middleware/pprof/pprof_test.go index b76a6f1c65..efa806c68a 100644 --- a/middleware/pprof/pprof_test.go +++ b/middleware/pprof/pprof_test.go @@ -104,6 +104,7 @@ func Test_Pprof_Subs(t *testing.T) { } for _, sub := range subs { + sub := sub t.Run(sub, func(t *testing.T) { t.Parallel() target := "/debug/pprof/" + sub @@ -133,6 +134,7 @@ func Test_Pprof_Subs_WithPrefix(t *testing.T) { } for _, sub := range subs { + sub := sub t.Run(sub, func(t *testing.T) { t.Parallel() target := "/federated-fiber/debug/pprof/" + sub From cc5e89f5876612edf4bdf48f02fa3b1eea808a56 Mon Sep 17 00:00:00 2001 From: Tiago Peczenyj Date: Thu, 5 Oct 2023 11:00:43 +0200 Subject: [PATCH 2/2] fix middleware/pprof tests --- middleware/pprof/pprof_test.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/middleware/pprof/pprof_test.go b/middleware/pprof/pprof_test.go index efa806c68a..c9c8e078a9 100644 --- a/middleware/pprof/pprof_test.go +++ b/middleware/pprof/pprof_test.go @@ -11,7 +11,6 @@ import ( ) func Test_Non_Pprof_Path(t *testing.T) { - t.Parallel() app := fiber.New(fiber.Config{DisableStartupMessage: true}) app.Use(New()) @@ -30,7 +29,6 @@ func Test_Non_Pprof_Path(t *testing.T) { } func Test_Non_Pprof_Path_WithPrefix(t *testing.T) { - t.Parallel() app := fiber.New(fiber.Config{DisableStartupMessage: true}) app.Use(New(Config{Prefix: "/federated-fiber"})) @@ -49,7 +47,6 @@ func Test_Non_Pprof_Path_WithPrefix(t *testing.T) { } func Test_Pprof_Index(t *testing.T) { - t.Parallel() app := fiber.New(fiber.Config{DisableStartupMessage: true}) app.Use(New()) @@ -69,7 +66,6 @@ func Test_Pprof_Index(t *testing.T) { } func Test_Pprof_Index_WithPrefix(t *testing.T) { - t.Parallel() app := fiber.New(fiber.Config{DisableStartupMessage: true}) app.Use(New(Config{Prefix: "/federated-fiber"})) @@ -89,7 +85,6 @@ func Test_Pprof_Index_WithPrefix(t *testing.T) { } func Test_Pprof_Subs(t *testing.T) { - t.Parallel() app := fiber.New(fiber.Config{DisableStartupMessage: true}) app.Use(New()) @@ -106,7 +101,6 @@ func Test_Pprof_Subs(t *testing.T) { for _, sub := range subs { sub := sub t.Run(sub, func(t *testing.T) { - t.Parallel() target := "/debug/pprof/" + sub if sub == "profile" { target += "?seconds=1" @@ -119,7 +113,6 @@ func Test_Pprof_Subs(t *testing.T) { } func Test_Pprof_Subs_WithPrefix(t *testing.T) { - t.Parallel() app := fiber.New(fiber.Config{DisableStartupMessage: true}) app.Use(New(Config{Prefix: "/federated-fiber"})) @@ -136,7 +129,6 @@ func Test_Pprof_Subs_WithPrefix(t *testing.T) { for _, sub := range subs { sub := sub t.Run(sub, func(t *testing.T) { - t.Parallel() target := "/federated-fiber/debug/pprof/" + sub if sub == "profile" { target += "?seconds=1" @@ -149,7 +141,6 @@ func Test_Pprof_Subs_WithPrefix(t *testing.T) { } func Test_Pprof_Other(t *testing.T) { - t.Parallel() app := fiber.New(fiber.Config{DisableStartupMessage: true}) app.Use(New()) @@ -164,7 +155,6 @@ func Test_Pprof_Other(t *testing.T) { } func Test_Pprof_Other_WithPrefix(t *testing.T) { - t.Parallel() app := fiber.New(fiber.Config{DisableStartupMessage: true}) app.Use(New(Config{Prefix: "/federated-fiber"})) @@ -180,7 +170,6 @@ func Test_Pprof_Other_WithPrefix(t *testing.T) { // go test -run Test_Pprof_Next func Test_Pprof_Next(t *testing.T) { - t.Parallel() app := fiber.New() app.Use(New(Config{ @@ -196,7 +185,6 @@ func Test_Pprof_Next(t *testing.T) { // go test -run Test_Pprof_Next_WithPrefix func Test_Pprof_Next_WithPrefix(t *testing.T) { - t.Parallel() app := fiber.New() app.Use(New(Config{