func (s *ModelSuite) assertDyingEnvironTransitionDyingToDead(c *gc.C, st *state.State) { // Add a service to prevent the model from transitioning directly to Dead. // Add the service before getting the Model, otherwise we'll have to run // the transaction twice, and hit the hook point too early. svc := factory.NewFactory(st).MakeService(c, nil) env, err := st.Model() c.Assert(err, jc.ErrorIsNil) // ProcessDyingModel is called by a worker after Destroy is called. To // avoid a race, we jump the gun here and test immediately after the // environement was set to dead. defer state.SetAfterHooks(c, st, func() { c.Assert(env.Refresh(), jc.ErrorIsNil) c.Assert(env.Life(), gc.Equals, state.Dying) err := svc.Destroy() c.Assert(err, jc.ErrorIsNil) c.Assert(st.ProcessDyingModel(), jc.ErrorIsNil) c.Assert(env.Refresh(), jc.ErrorIsNil) c.Assert(env.Life(), gc.Equals, state.Dead) }).Check() c.Assert(env.Destroy(), jc.ErrorIsNil) }
func (s *ModelSuite) assertDyingEnvironTransitionDyingToDead(c *gc.C, st *state.State) { env, err := st.Model() c.Assert(err, jc.ErrorIsNil) // ProcessDyingModel is called by a worker after Destroy is called. To // avoid a race, we jump the gun here and test immediately after the // environement was set to dead. defer state.SetAfterHooks(c, st, func() { c.Assert(env.Refresh(), jc.ErrorIsNil) c.Assert(env.Life(), gc.Equals, state.Dying) c.Assert(st.ProcessDyingModel(), jc.ErrorIsNil) c.Assert(env.Refresh(), jc.ErrorIsNil) c.Assert(env.Life(), gc.Equals, state.Dead) }).Check() c.Assert(env.Destroy(), jc.ErrorIsNil) }