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