Skip to content

Commit ce63116

Browse files
Copilotgaby
andauthored
🧹 chore: harden cache post test counter
Agent-Logs-Url: https://github.com/gofiber/fiber/sessions/c0423e5f-7f46-4ba0-ba0b-ef41c6eb7933 Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
1 parent 10ebd4d commit ce63116

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

middleware/cache/cache_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -936,10 +936,10 @@ func Test_Cache_Post(t *testing.T) {
936936

937937
app.Use(New())
938938

939-
count := 0
939+
var count atomic.Int32
940940
app.Post("/", func(c fiber.Ctx) error {
941-
count++
942-
return c.SendString(fmt.Sprintf("%d:%s", count, fiber.Query[string](c, "cache")))
941+
current := count.Add(1)
942+
return c.SendString(fmt.Sprintf("%d:%s", current, fiber.Query[string](c, "cache")))
943943
})
944944

945945
resp, err := app.Test(httptest.NewRequest(fiber.MethodPost, "/?cache=123", http.NoBody))

0 commit comments

Comments
 (0)