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
        
        -golang        1.24.4

      
        2
        
        -golangci-lint 2.1.6

      
        
        1
        +golang        1.25.0

      
        
        2
        +golangci-lint 2.4.0

      
        3
        3
         bun           1.2.17

      
        4
        4
         direnv        2.4.0

      
M go.mod
···
        1
        1
         module github.com/olexsmir/onasty

      
        2
        2
         

      
        3
        
        -go 1.24

      
        
        3
        +go 1.25

      
        4
        4
         

      
        5
        5
         require (

      
        6
        6
         	github.com/gin-contrib/cors v1.7.5

      
M internal/transport/http/ratelimit/ratelimit_test.go
···
        4
        4
         	"net/http"

      
        5
        5
         	"net/http/httptest"

      
        6
        6
         	"testing"

      
        
        7
        +	"testing/synctest"

      
        7
        8
         	"time"

      
        8
        9
         

      
        9
        10
         	"github.com/gin-gonic/gin"

      ···
        23
        24
         	assert.Len(t, limiter.visitors, 1)

      
        24
        25
         }

      
        25
        26
         

      
        26
        
        -// TODO: rewrite to use "testing/synctest" when it gets merged

      
        27
        27
         func TestRateLimiter_cleanupVisitors(t *testing.T) {

      
        28
        
        -	limiter := newLimiter(10, 20, time.Second/2)

      
        29
        
        -	limiter.getVisitor("192.168.9.1")

      
        30
        
        -	assert.Len(t, limiter.visitors, 1)

      
        
        28
        +	synctest.Test(t, func(t *testing.T) {

      
        
        29
        +		limiter := newLimiter(10, 20, time.Minute)

      
        
        30
        +		limiter.getVisitor("192.168.9.1")

      
        
        31
        +		assert.Len(t, limiter.visitors, 1)

      
        31
        32
         

      
        32
        
        -	time.Sleep(time.Second)

      
        33
        
        -	limiter.cleanupVisitors()

      
        34
        
        -	assert.Empty(t, limiter.visitors)

      
        
        33
        +		time.Sleep(61 * time.Second)

      
        
        34
        +

      
        
        35
        +		limiter.cleanupVisitors()

      
        
        36
        +		assert.Empty(t, limiter.visitors)

      
        
        37
        +	})

      
        35
        38
         }

      
        36
        39
         

      
        37
        40
         func TestMiddleware(t *testing.T) {