Merge branch '8784-dir-listings'
[arvados.git] / sdk / go / dispatch / throttle_test.go
index d91513ed4013b7fe7acd9bbe04eec332136836d5..d12659645e218b42dc18a9ec73471347666fb358 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
 package dispatch
 
 import (
@@ -18,21 +22,20 @@ type ThrottleTestSuite struct{}
 
 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)
 }