2014-11-13 15:26:14 +03:00
|
|
|
package redis
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
2015-01-25 22:24:27 +03:00
|
|
|
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
2014-11-13 15:26:14 +03:00
|
|
|
)
|
|
|
|
|
2015-01-25 22:24:27 +03:00
|
|
|
var _ = Describe("RateLimiter", func() {
|
2014-11-18 13:11:06 +03:00
|
|
|
var n = 100000
|
|
|
|
if testing.Short() {
|
|
|
|
n = 1000
|
|
|
|
}
|
2014-11-13 15:26:14 +03:00
|
|
|
|
2015-01-25 22:24:27 +03:00
|
|
|
It("should rate limit", func() {
|
|
|
|
rl := newRateLimiter(time.Minute, n)
|
|
|
|
for i := 0; i <= n; i++ {
|
|
|
|
Expect(rl.Check()).To(BeTrue())
|
|
|
|
}
|
|
|
|
Expect(rl.Check()).To(BeFalse())
|
|
|
|
})
|
2014-11-13 15:26:14 +03:00
|
|
|
|
2015-01-25 22:24:27 +03:00
|
|
|
})
|