Beispiel #1
0
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")
	}
}
Beispiel #2
0
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)
		}
	}
}
Beispiel #3
0
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")
	}
}
Beispiel #4
0
func assertReady(c *gc.C, s *schedule.Schedule, clock *coretesting.Clock, expect ...interface{}) {
	ready := s.Ready(clock.Now())
	c.Assert(ready, jc.DeepEquals, expect)
}