func TestDeleteAAPolicy(t *testing.T) { assert := assert.New(t) client := NewMockClient() client.On("Delete", "http://localhost/v2/antiAffinityPolicies/test/12345", nil).Return(nil) service := aa.New(client) err := service.Delete("12345") assert.Nil(err) client.AssertExpectations(t) }
func TestGetAllAAPolicy(t *testing.T) { assert := assert.New(t) client := NewMockClient() client.On("Get", "http://localhost/v2/antiAffinityPolicies/test", mock.Anything).Return(nil) service := aa.New(client) resp, err := service.GetAll() assert.Nil(err) assert.Equal(2, len(resp.Items)) client.AssertExpectations(t) }
func TestGetAAPolicy(t *testing.T) { assert := assert.New(t) client := NewMockClient() client.On("Get", "http://localhost/v2/antiAffinityPolicies/test/12345", mock.Anything).Return(nil) service := aa.New(client) id := "12345" resp, err := service.Get(id) assert.Nil(err) assert.Equal(id, resp.ID) client.AssertExpectations(t) }
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 }
func TestUpdateAAPolicy(t *testing.T) { assert := assert.New(t) client := NewMockClient() client.On("Put", "http://localhost/v2/antiAffinityPolicies/test/12345", mock.Anything, mock.Anything).Return(nil) service := aa.New(client) id := "12345" name := "aa1" resp, err := service.Update(id, name) assert.Nil(err) assert.Equal(name, resp.Name) client.AssertExpectations(t) }
func TestCreateAAPolicy(t *testing.T) { assert := assert.New(t) client := NewMockClient() client.On("Post", "http://localhost/v2/antiAffinityPolicies/test", mock.Anything, mock.Anything).Return(nil) service := aa.New(client) name := "aa1" location := "dc1" resp, err := service.Create(name, location) assert.Nil(err) assert.Equal(name, resp.Name) assert.Equal(location, resp.Location) assert.NotEmpty(resp.ID) assert.NotEmpty(resp.Links) client.AssertExpectations(t) }