Merge branch '8784-dir-listings'
[arvados.git] / sdk / go / dispatch / throttle_test.go
index ba657830f565d29e5199f16ebca35629628b1fc9..d12659645e218b42dc18a9ec73471347666fb358 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
 package dispatch
 
 import (
@@ -12,27 +16,26 @@ func Test(t *testing.T) {
        check.TestingT(t)
 }
 
-var _ = check.Suite(&Suite{})
+var _ = check.Suite(&ThrottleTestSuite{})
 
-type Suite struct{}
+type ThrottleTestSuite struct{}
 
-func (*Suite) TestThrottle(c *check.C) {
+func (*ThrottleTestSuite) TestThrottle(c *check.C) {
        uuid := "zzzzz-zzzzz-zzzzzzzzzzzzzzz"
+       t0 := throttle{}
+       c.Check(t0.Check(uuid), check.Equals, true)
+       c.Check(t0.Check(uuid), check.Equals, true)
 
-       t := throttle{}
-       c.Check(t.Check(uuid), check.Equals, true)
-       c.Check(t.Check(uuid), check.Equals, true)
-
-       t = throttle{hold: time.Nanosecond}
-       c.Check(t.Check(uuid), check.Equals, true)
+       tNs := throttle{hold: time.Nanosecond}
+       c.Check(tNs.Check(uuid), check.Equals, true)
        time.Sleep(time.Microsecond)
-       c.Check(t.Check(uuid), check.Equals, true)
-
-       t = throttle{hold: time.Minute}
-       c.Check(t.Check(uuid), check.Equals, true)
-       c.Check(t.Check(uuid), check.Equals, false)
-       c.Check(t.Check(uuid), check.Equals, false)
-       t.seen[uuid].last = time.Now().Add(-time.Hour)
-       c.Check(t.Check(uuid), check.Equals, true)
-       c.Check(t.Check(uuid), check.Equals, false)
+       c.Check(tNs.Check(uuid), check.Equals, true)
+
+       tMin := throttle{hold: time.Minute}
+       c.Check(tMin.Check(uuid), check.Equals, true)
+       c.Check(tMin.Check(uuid), check.Equals, false)
+       c.Check(tMin.Check(uuid), check.Equals, false)
+       tMin.seen[uuid].last = time.Now().Add(-time.Hour)
+       c.Check(tMin.Check(uuid), check.Equals, true)
+       c.Check(tMin.Check(uuid), check.Equals, false)
 }