func (s *FilterSuite) TestUnitDeath(c *gc.C) { f, err := newFilter(s.uniter, s.unit.Tag()) c.Assert(err, gc.IsNil) defer f.Stop() // no AssertStop, we test for an error below asserter := coretesting.NotifyAsserterC{ Precond: func() { s.BackingState.StartSync() }, C: c, Chan: f.UnitDying(), } asserter.AssertNoReceive() // Irrelevant change. err = s.unit.SetResolved(state.ResolvedRetryHooks) c.Assert(err, gc.IsNil) asserter.AssertNoReceive() // Set dying. err = s.unit.SetStatus(params.StatusStarted, "", nil) c.Assert(err, gc.IsNil) err = s.unit.Destroy() c.Assert(err, gc.IsNil) asserter.AssertClosed() // Another irrelevant change. err = s.unit.ClearResolved() c.Assert(err, gc.IsNil) asserter.AssertClosed() // Set dead. err = s.unit.EnsureDead() c.Assert(err, gc.IsNil) s.assertAgentTerminates(c, f) }
// Ensure we get a signal on f.Dead() func (s *FilterSuite) assertFilterDies(c *gc.C, f *filter) { asserter := coretesting.NotifyAsserterC{ Precond: func() { s.BackingState.StartSync() }, C: c, Chan: f.Dead(), } asserter.AssertClosed() }