7 check "gopkg.in/check.v1"
10 // Gocheck boilerplate
11 func Test(t *testing.T) {
15 var _ = check.Suite(&ThrottleTestSuite{})
17 type ThrottleTestSuite struct{}
19 func (*ThrottleTestSuite) TestThrottle(c *check.C) {
20 uuid := "zzzzz-zzzzz-zzzzzzzzzzzzzzz"
22 c.Check(t0.Check(uuid), check.Equals, true)
23 c.Check(t0.Check(uuid), check.Equals, true)
25 tNs := throttle{hold: time.Nanosecond}
26 c.Check(tNs.Check(uuid), check.Equals, true)
27 time.Sleep(time.Microsecond)
28 c.Check(tNs.Check(uuid), check.Equals, true)
30 tMin := throttle{hold: time.Minute}
31 c.Check(tMin.Check(uuid), check.Equals, true)
32 c.Check(tMin.Check(uuid), check.Equals, false)
33 c.Check(tMin.Check(uuid), check.Equals, false)
34 tMin.seen[uuid].last = time.Now().Add(-time.Hour)
35 c.Check(tMin.Check(uuid), check.Equals, true)
36 c.Check(tMin.Check(uuid), check.Equals, false)