all repos

onasty @ bf8dc57

a one-time notes service
3 files changed, 13 insertions(+), 10 deletions(-)
chore: update go (#192)

- Update go version to 1.25
- Use `testing/synctest` in ratelimiter tests
Author: Olexandr Smirnov ss2316544@gmail.com
Committed by: GitHub noreply@github.com
Committed at: 2025-08-24 17:37:08 +0300
Parent: 7ff621d
M .tool-versions

@@ -1,4 +1,4 @@

-golang 1.24.4 -golangci-lint 2.1.6 +golang 1.25.0 +golangci-lint 2.4.0 bun 1.2.17 direnv 2.4.0
M go.mod

@@ -1,6 +1,6 @@

module github.com/olexsmir/onasty -go 1.24 +go 1.25 require ( github.com/gin-contrib/cors v1.7.5
M internal/transport/http/ratelimit/ratelimit_test.go

@@ -4,6 +4,7 @@ import (

"net/http" "net/http/httptest" "testing" + "testing/synctest" "time" "github.com/gin-gonic/gin"

@@ -23,15 +24,17 @@

assert.Len(t, limiter.visitors, 1) } -// TODO: rewrite to use "testing/synctest" when it gets merged func TestRateLimiter_cleanupVisitors(t *testing.T) { - limiter := newLimiter(10, 20, time.Second/2) - limiter.getVisitor("192.168.9.1") - assert.Len(t, limiter.visitors, 1) + synctest.Test(t, func(t *testing.T) { + limiter := newLimiter(10, 20, time.Minute) + limiter.getVisitor("192.168.9.1") + assert.Len(t, limiter.visitors, 1) - time.Sleep(time.Second) - limiter.cleanupVisitors() - assert.Empty(t, limiter.visitors) + time.Sleep(61 * time.Second) + + limiter.cleanupVisitors() + assert.Empty(t, limiter.visitors) + }) } func TestMiddleware(t *testing.T) {