예제 #1
0
func (s *AddresserSuite) TestRemoveSuccess(c *gc.C) {
	tag1 := names.NewIPAddressTag("11111111-0000-0000-0000-000000000000")
	tag2 := names.NewIPAddressTag("22222222-0000-0000-0000-000000000000")
	tag3 := names.NewIPAddressTag("33333333-0000-0000-0000-000000000000")

	var called int
	args := params.Entities{
		Entities: []params.Entity{
			{Tag: tag1.String()},
			{Tag: tag2.String()},
			{Tag: tag3.String()},
		},
	}
	results := params.ErrorResults{
		Results: []params.ErrorResult{{nil}, {nil}, {nil}},
	}
	apiCaller := successAPICaller(c, "Remove", args, results, &called)
	api := addresser.NewAPI(apiCaller)

	ipAddress1 := addresser.NewIPAddress(api, tag1, params.Alive)
	ipAddress2 := addresser.NewIPAddress(api, tag2, params.Dying)
	ipAddress3 := addresser.NewIPAddress(api, tag3, params.Dead)

	err := api.Remove(ipAddress1, ipAddress2, ipAddress3)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(called, gc.Equals, 1)
}
예제 #2
0
func (s *AddresserSuite) TestRemoveClientError(c *gc.C) {
	var called int
	tag := names.NewIPAddressTag("00000000-0000-0000-0000-000000000000")
	apiCaller := clientErrorAPICaller(c, "Remove", nil, &called)
	api := addresser.NewAPI(apiCaller)

	ipAddress := addresser.NewIPAddress(api, tag, params.Alive)
	err := ipAddress.Remove()
	c.Assert(err, gc.ErrorMatches, "client error!")
	c.Assert(called, gc.Equals, 1)
}
예제 #3
0
func (s *AddresserSuite) TestRemoveServerError(c *gc.C) {
	var called int
	tag := names.NewIPAddressTag("00000000-0000-0000-0000-000000000000")
	args := params.Entities{
		Entities: []params.Entity{{Tag: tag.String()}},
	}
	results := params.ErrorResults{
		Results: []params.ErrorResult{{apiservertesting.ServerError("server boom!")}},
	}
	apiCaller := successAPICaller(c, "Remove", args, results, &called)
	api := addresser.NewAPI(apiCaller)

	ipAddress := addresser.NewIPAddress(api, tag, params.Alive)
	err := ipAddress.Remove()
	c.Assert(err, gc.ErrorMatches, "server boom!")
	c.Assert(called, gc.Equals, 1)
}