func (suite *StateSuite) TestGetAddressesIgnoresNils(c *gc.C) { instances := []instance.Instance{ nil, &mockInstance{addresses: network.NewAddresses("foo")}, nil, &mockInstance{addresses: network.NewAddresses("bar")}, nil, } c.Check(common.GetAddresses(instances), gc.DeepEquals, []string{"foo", "bar"}) c.Check(common.GetAddresses(nil), gc.DeepEquals, []string{}) }
func (suite *StateSuite) TestGetAddressesReturnsNames(c *gc.C) { instances := []instance.Instance{ &mockInstance{addresses: network.NewAddresses("foo")}, &mockInstance{addresses: network.NewAddresses("bar")}, } c.Check(common.GetAddresses(instances), gc.DeepEquals, []string{"foo", "bar"}) }
func (suite *StateSuite) TestGetAddressesIgnoresAddressesErrors(c *gc.C) { instances := []instance.Instance{ &mockInstance{ addresses: network.NewAddresses("one"), addressesErr: errors.New("ignored"), }, &mockInstance{addresses: network.NewAddresses("two", "three")}, } c.Check(common.GetAddresses(instances), gc.DeepEquals, []string{"two", "three"}) }
func (suite *StateSuite) TestGetAddressesIgnoresInstancesWithoutAddrs(c *gc.C) { instances := []instance.Instance{&mockInstance{}} c.Check(common.GetAddresses(instances), gc.DeepEquals, []string{}) }
func (suite *StateSuite) TestGetAddressesAcceptsNil(c *gc.C) { result := common.GetAddresses(nil) c.Check(result, gc.DeepEquals, []string{}) }