Exemple #1
0
func (s *machineSuite) TestForceDestroyMachines(c *gc.C) {
	st := mockState{
		machines: map[string]*mockMachine{
			"1": {},
			"2": {life: state.Dying},
		},
	}
	err := common.MockableDestroyMachines(&st, true, "1", "2")

	c.Assert(st.machines["1"].Life(), gc.Equals, state.Dying)
	c.Assert(st.machines["1"].forceDestroyCalled, jc.IsTrue)
	c.Assert(st.machines["2"].forceDestroyCalled, jc.IsTrue)

	c.Assert(err, jc.ErrorIsNil)
}
Exemple #2
0
func (s *machineSuite) TestDestroyMachines(c *gc.C) {
	st := mockState{
		machines: map[string]*mockMachine{
			"1": {},
			"2": {destroyErr: errors.New("unit exists error")},
			"3": {life: state.Dying},
		},
	}
	err := common.MockableDestroyMachines(&st, false, "1", "2", "3", "4")

	c.Assert(st.machines["1"].Life(), gc.Equals, state.Dying)
	c.Assert(st.machines["1"].forceDestroyCalled, jc.IsFalse)

	c.Assert(st.machines["2"].Life(), gc.Equals, state.Alive)
	c.Assert(st.machines["2"].forceDestroyCalled, jc.IsFalse)

	c.Assert(st.machines["3"].forceDestroyCalled, jc.IsFalse)
	c.Assert(st.machines["3"].destroyCalled, jc.IsFalse)

	c.Assert(err, gc.ErrorMatches, "some machines were not destroyed: unit exists error; machine 4 does not exist")
}