Example #1
0
func TestGetDatacenter(t *testing.T) {
	assert := assert.New(t)

	client := NewMockClient()
	client.On("Get", "http://localhost/v2/datacenters/test/dc1?groupLinks=true", mock.Anything).Return(nil)
	service := dc.New(client)

	id := "dc1"
	resp, err := service.Get(id)

	assert.Nil(err)
	assert.Equal(id, resp.ID)
}
Example #2
0
func TestGetDatacenters(t *testing.T) {
	assert := assert.New(t)

	client := NewMockClient()
	client.On("Get", "http://localhost/v2/datacenters/test", mock.Anything).Return(nil)
	service := dc.New(client)

	resp, err := service.GetAll()

	assert.Nil(err)
	assert.Equal(1, len(resp))
	assert.Equal("dc1", resp[0].ID)
}
Example #3
0
func New(config api.Config) *Client {
	c := &Client{
		client: api.New(config),
	}

	c.Server = server.New(c.client)
	c.Status = status.New(c.client)
	c.AA = aa.New(c.client)
	c.Alert = alert.New(c.client)
	c.LB = lb.New(c.client)
	c.Group = group.New(c.client)
	c.DC = dc.New(c.client)

	return c
}