func (s *EnvironSuite) assertDyingEnvironTransitionDyingToDead(c *gc.C, st *state.State) { env, err := st.Environment() c.Assert(err, jc.ErrorIsNil) // ProcessDyingEnviron 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.ProcessDyingEnviron(), jc.ErrorIsNil) c.Assert(env.Refresh(), jc.ErrorIsNil) c.Assert(env.Life(), gc.Equals, state.Dead) }).Check() c.Assert(env.Destroy(), jc.ErrorIsNil) }