コード例 #1
0
ファイル: assign_test.go プロジェクト: jameinel/core
func (s *AssignSuite) assertAssignedUnit(c *gc.C, unit *state.Unit) string {
	// Get service networks.
	service, err := unit.Service()
	c.Assert(err, gc.IsNil)
	includeNetworks, excludeNetworks, err := service.Networks()
	c.Assert(err, gc.IsNil)
	// Check the machine on the unit is set.
	machineId, err := unit.AssignedMachineId()
	c.Assert(err, gc.IsNil)
	// Check that the principal is set on the machine.
	machine, err := s.State.Machine(machineId)
	c.Assert(err, gc.IsNil)
	include, exclude, err := machine.RequestedNetworks()
	c.Assert(err, gc.IsNil)
	c.Assert(include, gc.DeepEquals, includeNetworks)
	c.Assert(exclude, gc.DeepEquals, excludeNetworks)
	machineUnits, err := machine.Units()
	c.Assert(err, gc.IsNil)
	c.Assert(machineUnits, gc.HasLen, 1)
	// Make sure it is the right unit.
	c.Assert(machineUnits[0].Name(), gc.Equals, unit.Name())
	return machineId
}