コード例 #1
0
ファイル: machine_test.go プロジェクト: rif/golang-stuff
func (s *MachineSuite) TestDestroyAbort(c *C) {
	defer state.SetBeforeHooks(c, s.State, func() {
		c.Assert(s.machine.Destroy(), IsNil)
	}).Check()
	err := s.machine.Destroy()
	c.Assert(err, IsNil)
}
コード例 #2
0
func (s *MinUnitsSuite) testEnsureMinUnitsBefore(c *C, f func(), minUnits, expectedUnits int) {
	service := s.service
	err := service.SetMinUnits(minUnits)
	c.Assert(err, IsNil)
	defer state.SetBeforeHooks(c, s.State, f).Check()
	err = service.EnsureMinUnits()
	c.Assert(err, IsNil)
	assertAllUnits(c, service, expectedUnits)
}
コード例 #3
0
ファイル: machine_test.go プロジェクト: rif/golang-stuff
func (s *MachineSuite) TestRemoveAbort(c *C) {
	err := s.machine.EnsureDead()
	c.Assert(err, IsNil)

	defer state.SetBeforeHooks(c, s.State, func() {
		c.Assert(s.machine.Remove(), IsNil)
	}).Check()
	err = s.machine.Remove()
	c.Assert(err, IsNil)
}
コード例 #4
0
func (s *MinUnitsSuite) TestEnsureMinUnitsDestroyServiceBefore(c *C) {
	s.addUnits(c, 1)
	err := s.service.SetMinUnits(42)
	c.Assert(err, IsNil)
	defer state.SetBeforeHooks(c, s.State, func() {
		err := s.service.Destroy()
		c.Assert(err, IsNil)
	}).Check()
	c.Assert(s.service.EnsureMinUnits(), ErrorMatches,
		`cannot ensure minimum units for service "dummy-service": service is not alive`)
}
コード例 #5
0
func (s *MinUnitsSuite) TestMinUnitsRemoveBefore(c *C) {
	err := s.service.SetMinUnits(41)
	c.Assert(err, IsNil)
	defer state.SetBeforeHooks(c, s.State, func() {
		err := s.service.SetMinUnits(0)
		c.Assert(err, IsNil)
		s.assertRevno(c, 0, mgo.ErrNotFound)
	}).Check()
	err = s.service.SetMinUnits(0)
	c.Assert(err, IsNil)
	c.Assert(s.service.MinUnits(), Equals, 0)
}
コード例 #6
0
ファイル: machine_test.go プロジェクト: rif/golang-stuff
func (s *MachineSuite) TestDestroyCancel(c *C) {
	svc, err := s.State.AddService("wordpress", s.AddTestingCharm(c, "wordpress"))
	c.Assert(err, IsNil)
	unit, err := svc.AddUnit()
	c.Assert(err, IsNil)

	defer state.SetBeforeHooks(c, s.State, func() {
		c.Assert(unit.AssignToMachine(s.machine), IsNil)
	}).Check()
	err = s.machine.Destroy()
	c.Assert(err, FitsTypeOf, &state.HasAssignedUnitsError{})
}
コード例 #7
0
func (s *MinUnitsSuite) testDestroyOrRemoveServiceBefore(c *C, initial, input int, preventRemoval bool) {
	err := s.service.SetMinUnits(initial)
	c.Assert(err, IsNil)
	expectedErr := `cannot set minimum units for service "dummy-service": service "dummy-service" not found`
	if preventRemoval {
		expectedErr = `cannot set minimum units for service "dummy-service": service is no longer alive`
		s.addUnits(c, 1)
	}
	defer state.SetBeforeHooks(c, s.State, func() {
		err := s.service.Destroy()
		c.Assert(err, IsNil)
	}).Check()
	err = s.service.SetMinUnits(input)
	c.Assert(err, ErrorMatches, expectedErr)
	s.assertRevno(c, 0, mgo.ErrNotFound)
}
コード例 #8
0
ファイル: unit_test.go プロジェクト: hivetech/judo.legacy
func (s *UnitSuite) TestGetSetPrivateAddress(c *C) {
	_, ok := s.unit.PrivateAddress()
	c.Assert(ok, Equals, false)

	err := s.unit.SetPrivateAddress("example.local")
	c.Assert(err, IsNil)
	address, ok := s.unit.PrivateAddress()
	c.Assert(ok, Equals, true)
	c.Assert(address, Equals, "example.local")

	defer state.SetBeforeHooks(c, s.State, func() {
		c.Assert(s.unit.Destroy(), IsNil)
	}).Check()
	err = s.unit.SetPrivateAddress("example.local")
	c.Assert(err, ErrorMatches, `cannot set private address of unit "wordpress/0": unit not found`)
}