コード例 #1
0
ファイル: aa_test.go プロジェクト: CenturyLinkCloud/clc-sdk
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)
}
コード例 #2
0
ファイル: aa_test.go プロジェクト: CenturyLinkCloud/clc-sdk
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)
}
コード例 #3
0
ファイル: aa_test.go プロジェクト: CenturyLinkCloud/clc-sdk
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)
}
コード例 #4
0
ファイル: client.go プロジェクト: RezaDKhan/terraform
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
}
コード例 #5
0
ファイル: aa_test.go プロジェクト: CenturyLinkCloud/clc-sdk
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)
}
コード例 #6
0
ファイル: aa_test.go プロジェクト: CenturyLinkCloud/clc-sdk
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)
}