Exemplo n.º 1
0
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{})
}
Exemplo n.º 2
0
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"})
}
Exemplo n.º 3
0
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"})
}
Exemplo n.º 4
0
func (suite *StateSuite) TestGetAddressesIgnoresInstancesWithoutAddrs(c *gc.C) {
	instances := []instance.Instance{&mockInstance{}}
	c.Check(common.GetAddresses(instances), gc.DeepEquals, []string{})
}
Exemplo n.º 5
0
func (suite *StateSuite) TestGetAddressesAcceptsNil(c *gc.C) {
	result := common.GetAddresses(nil)
	c.Check(result, gc.DeepEquals, []string{})
}