func (s *PresenceSuite) TestExpiry(c *gc.C) { w := presence.NewWatcher(s.presence) p := presence.NewPinger(s.presence, "a") defer w.Stop() defer p.Stop() ch := make(chan presence.Change) w.Watch("a", ch) assertChange(c, ch, presence.Change{"a", false}) c.Assert(p.Start(), gc.IsNil) w.StartSync() assertChange(c, ch, presence.Change{"a", true}) // Still alive in previous slot. presence.FakeTimeSlot(1) w.StartSync() assertNoChange(c, ch) // Two last slots are empty. presence.FakeTimeSlot(2) w.StartSync() assertChange(c, ch, presence.Change{"a", false}) // Already dead so killing isn't noticed. p.Kill() w.StartSync() assertNoChange(c, ch) }
func (s *PresenceSuite) SetUpTest(c *gc.C) { s.LoggingSuite.SetUpTest(c) s.MgoSuite.SetUpTest(c) db := s.MgoSuite.Session.DB("presence") s.presence = db.C("presence") s.pings = db.C("presence.pings") presence.FakeTimeSlot(0) }