From 56e74239d6b34df8f30ef046f0b0ff4ff0866a71 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Sun, 14 Jun 2015 23:53:32 -0800 Subject: first commit --- .../src/gopkg.in/redis.v2/rate_limit_test.go | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Godeps/_workspace/src/gopkg.in/redis.v2/rate_limit_test.go (limited to 'Godeps/_workspace/src/gopkg.in/redis.v2/rate_limit_test.go') diff --git a/Godeps/_workspace/src/gopkg.in/redis.v2/rate_limit_test.go b/Godeps/_workspace/src/gopkg.in/redis.v2/rate_limit_test.go new file mode 100644 index 000000000..2f0d41a2e --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/redis.v2/rate_limit_test.go @@ -0,0 +1,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") + } +} -- cgit v1.2.3-1-g7c22