本文整理匯總了Golang中github.com/juju/juju/testing.Clock類的典型用法代碼示例。如果您正苦於以下問題:Golang Clock類的具體用法?Golang Clock怎麽用?Golang Clock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Clock類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: waitAlarm
func waitAlarm(c *gc.C, clock *coretesting.Clock) {
select {
case <-clock.Alarms():
case <-time.After(coretesting.LongWait):
c.Fatalf("timed out waiting for SUT to use clock")
}
}
示例2: waitAlarms
func waitAlarms(c *gc.C, clock *testing.Clock, count int) {
timeout := time.After(testing.LongWait)
for i := 0; i < count; i++ {
select {
case <-clock.Alarms():
case <-timeout:
c.Fatalf("timed out waiting for %dth alarm set", i)
}
}
}
示例3: assertNextOp
func assertNextOp(c *gc.C, s *schedule.Schedule, clock *coretesting.Clock, d time.Duration) {
next := s.Next()
c.Assert(next, gc.NotNil)
if d > 0 {
select {
case <-next:
c.Fatal("Next channel signalled too soon")
default:
}
}
// temporarily move time forward
clock.Advance(d)
defer clock.Advance(-d)
select {
case _, ok := <-next:
c.Assert(ok, jc.IsTrue)
// the time value is unimportant to us
default:
c.Fatal("Next channel not signalled")
}
}
示例4: assertReady
func assertReady(c *gc.C, s *schedule.Schedule, clock *coretesting.Clock, expect ...interface{}) {
ready := s.Ready(clock.Now())
c.Assert(ready, jc.DeepEquals, expect)
}