/usr/share/gocode/src/gopkg.in/redis.v2/rate_limit_test.go is in golang-gopkg-redis.v2-dev 2.3.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 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")
}
}
|