Esempio n. 1
0
func (s *clockSuite) TestClockAdvance(c *gc.C) {
	now := time.Date(2015, 9, 10, 13, 14, 15, 0, time.UTC)
	tc := clocktest.NewClock(now)
	advance := 5 * time.Minute
	tc.Advance(advance)
	c.Assert(tc.Now(), gc.Equals, now.Add(advance))
}
Esempio n. 2
0
func (s *clockSuite) TestClockAfter(c *gc.C) {
	now := time.Date(2015, 9, 10, 13, 14, 15, 0, time.UTC)
	tc := clocktest.NewClock(now)
	advance := 5 * time.Minute

	alarm := tc.After(advance)

	select {
	case <-alarm:
		c.Error("alarm shouldn't fire yet")
	default:
		// all good
	}

	tc.Advance(advance)

	select {
	case when := <-alarm:
		c.Assert(when, gc.Equals, tc.Now())
	case <-time.After(time.Millisecond):
		c.Error("alarm should have fired")
	}
}
Esempio n. 3
0
func (s *clockSuite) TestClockNow(c *gc.C) {
	now := time.Date(2015, 9, 10, 13, 14, 15, 0, time.UTC)
	tc := clocktest.NewClock(now)
	c.Assert(tc.Now(), gc.Equals, now)
}