本文整理汇总了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)
}