1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-19 11:43:14 +03:00
Files
go-redis/rate_limit_test.go
Vladimir Mihailenco 20c738a103 Enable race tests.
2014-11-18 12:11:06 +02:00

32 lines
406 B
Go

package redis
import (
"sync"
"testing"
"time"
)
func TestRateLimiter(t *testing.T) {
var n = 100000
if testing.Short() {
n = 1000
}
rl := newRateLimiter(time.Minute, n)
wg := &sync.WaitGroup{}
for i := 0; i < n; i++ {
wg.Add(1)
go func() {
if !rl.Check() {
panic("check failed")
}
wg.Done()
}()
}
wg.Wait()
if rl.Check() && rl.Check() {
t.Fatal("check passed")
}
}