func TestFindEndpointVersionNoValueFoundNoErrorShouldOccur(t *testing.T) {
	apiServer := testUtil.CreateGetJSONTestRequestServerVerifyURL(t, tokn, hpHelionImageVersionPayload, "")
	defer apiServer.Close()

	url, err := FindEndpointVersion(apiServer.URL, tokn, nil, "v2.0")
	testUtil.IsNil(t, err)
	testUtil.Equals(t, "", url)
}
func TestFindEndpointVersionValid(t *testing.T) {
	apiServer := testUtil.CreateGetJSONTestRequestServerVerifyURL(t, tokn, hpHelionImageVersionPayload, "")
	defer apiServer.Close()

	url, err := FindEndpointVersion(apiServer.URL, tokn, nil, "v1.0")
	testUtil.IsNil(t, err)
	testUtil.Equals(t, "http://region-a.geo-1.images.hpcloudsvc.com/v1/", url)
}
func TestGetSecurityGroup(t *testing.T) {
	apiServer := testUtil.CreateGetJSONTestRequestServerVerifyURL(t, tokn, sampleSecurityGroupJSONResponse, "/os-security-groups/w9236264")
	defer apiServer.Close()

	service := CreateComputeService(apiServer.URL)
	sg, err := service.SecurityGroup("w9236264")
	testUtil.IsNil(t, err)
	testUtil.Equals(t, sampleSecurityGroup, sg)
}
func TestGetServerSecurityGroups(t *testing.T) {
	apiServer := testUtil.CreateGetJSONTestRequestServerVerifyURL(t, tokn, sampleSecurityGroupsJSONResponse, "/os-security-groups/servers/aghagr")
	defer apiServer.Close()

	service := CreateComputeService(apiServer.URL)
	sgs, err := service.ServerSecurityGroups("aghagr")
	testUtil.IsNil(t, err)
	testUtil.Equals(t, len(sgs), 1)
	testUtil.Equals(t, sampleSecurityGroup, sgs[0])
}
Exemplo n.º 5
0
func TestServerDetailNoImage(t *testing.T) {
	apiServer := testUtil.CreateGetJSONTestRequestServerVerifyURL(t, tokn, serverDetailNoImagePayload, "/servers/my_server")
	defer apiServer.Close()

	service := CreateComputeService(apiServer.URL)

	result, err := service.ServerDetail("my_server")
	testUtil.IsNil(t, err)

	testUtil.Equals(t, serverDetailNoImage, result)
}
Exemplo n.º 6
0
func TestQueryServersDetail(t *testing.T) {
	apiServer := testUtil.CreateGetJSONTestRequestServerVerifyURL(t, tokn, serversDetailJSONPayload, "/servers/detail?limit=21&name=foo")
	defer apiServer.Close()

	computeService := CreateComputeService(apiServer.URL)
	queryParameters := ServerDetailQueryParameters{Name: "foo"}
	servers, err := computeService.QueryServersDetail(queryParameters)

	testUtil.IsNil(t, err)
	testUtil.Assert(t, len(servers) == 1, "Expected 1 server.")
	testUtil.Equals(t, serverDetail, servers[0])
}
Exemplo n.º 7
0
func TestLimits(t *testing.T) {
	expectedLimits := limitsContainer{}
	json.Unmarshal([]byte(sampleLimits), &expectedLimits)
	apiServer := testUtil.CreateGetJSONTestRequestServerVerifyURL(t, tokn, sampleLimits, "/limits")
	defer apiServer.Close()

	service := CreateComputeService(apiServer.URL)
	limits, err := service.Limits()
	if err != nil {
		t.Error(err)
	}

	testUtil.Equals(t, expectedLimits.Limits, limits)
}
func TestEndpoints(t *testing.T) {
	apiServer := testUtil.CreateGetJSONTestRequestServerVerifyURL(t, tokn, hpHelionImageVersionPayload, "")
	defer apiServer.Close()

	versions, err := Endpoints(apiServer.URL, tokn, nil)
	testUtil.IsNil(t, err)
	numVersions := len(versions)
	testUtil.Equals(t, 2, numVersions)

	testUtil.Equals(t, "v1.1", versions[0].ID)
	testUtil.Equals(t, "CURRENT", versions[0].Status)

	testUtil.Equals(t, "v1.0", versions[1].ID)
	testUtil.Equals(t, "SUPPORTED", versions[1].Status)
}