Esempio n. 1
0
func TestPollStatus_ErrorGettingStatus(t *testing.T) {
	assert := assert.New(t)

	client := NewMockClient()
	client.On("Get", "http://localhost/v2/operations/test/status/12345", mock.Anything).Return(errors.New(""))
	service := status.New(client)
	service.PollInterval = 1 * time.Microsecond

	err := service.Poll("12345", make(chan *status.Response, 1))

	assert.NotNil(err)
}
Esempio n. 2
0
func TestGetStatus(t *testing.T) {
	assert := assert.New(t)

	client := NewMockClient()
	client.On("Get", "http://localhost/v2/operations/test/status/12345", mock.Anything).Return(nil)
	service := status.New(client)
	resp, err := service.Get("12345")

	assert.Nil(err)
	assert.True(resp.Running())
	client.AssertExpectations(t)
}
Esempio n. 3
0
func TestStatusBlueprintOperation(t *testing.T) {
	assert := assert.New(t)

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

	resp, err := service.GetBlueprint("blueprint")

	assert.Nil(err)
	assert.Equal("blueprintOperation", resp.RequestType)
	assert.Equal("network", resp.Summary.Links[0].Rel)
}
Esempio n. 4
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
}
Esempio n. 5
0
func TestPollStatus(t *testing.T) {
	assert := assert.New(t)

	client := NewMockClient()
	client.On("Get", "http://localhost/v2/operations/test/status/12345", mock.Anything).Return(nil)
	service := status.New(client)
	service.PollInterval = 1 * time.Microsecond

	poll := make(chan *status.Response, 1)
	err := service.Poll("12345", poll)

	status := <-poll

	assert.Nil(err)
	assert.True(status.Complete())
	client.AssertExpectations(t)
}