本文整理汇总了Golang中git/openstack/org/stackforge/golang-client/git/testUtil.Equals函数的典型用法代码示例。如果您正苦于以下问题:Golang Equals函数的具体用法?Golang Equals怎么用?Golang Equals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Equals函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestErrorIsRateLimitShouldSucceed
func TestErrorIsRateLimitShouldSucceed(t *testing.T) {
sampleRateLimit := compute.RateLimit{
NextAvailable: testTime,
Remaining: 120,
Unit: "MINUTE",
Value: 120,
Verb: "POST",
}
sampleBytes, _ := json.Marshal(sampleRateLimit)
samplejson := `{ "limit": ` + string(sampleBytes) + " }"
val := map[string][]string{"Content-Type": []string{"application/json"}}
reader := testUtil.NewTestReadCloser([]byte(samplejson))
response := http.Response{
Header: val,
StatusCode: 413,
Body: reader,
}
httpStatus := misc.NewHTTPStatus(&response, "message")
isRateLimit, rateLimit := compute.ErrorIsRateLimit(httpStatus)
testUtil.Equals(t, true, isRateLimit)
testUtil.Equals(t, sampleRateLimit, rateLimit)
}
示例2: TestDefaultServiceResolverURLNotFoundInServiceCatalogError
func TestDefaultServiceResolverURLNotFoundInServiceCatalogError(t *testing.T) {
apiServer := testVersionList(t)
defer apiServer.Close()
url, err := defaultGetVersionURLFilterByVersion("t", nil, []service{}, "image", "region1", "1")
testUtil.Equals(t, "", url)
testUtil.Assert(t, err != nil, "Expected an error")
testUtil.Equals(t, "ServiceCatalog does not contain serviceType 'image'", err.Error())
}
示例3: TestDefaultServiceURLFoundInCatalogErrorsNotFoundInVersionList
func TestDefaultServiceURLFoundInCatalogErrorsNotFoundInVersionList(t *testing.T) {
apiServer := testVersionList(t)
defer apiServer.Close()
sc := []service{createService("image", "glance", endpoint{Region: "region1", PublicURL: apiServer.URL + "/publicurl", VersionList: apiServer.URL + "/versionlist"})}
url, err := defaultGetVersionURLFilterByVersion("t", nil, sc, "image", "region1", "2")
testUtil.Equals(t, "", url)
testUtil.Assert(t, err != nil, "Expected an error")
testUtil.Equals(t, "Found serviceType 'image' in the ServiceCatalog but cannot find an endpoint with the specified region 'region1' and version '2'", err.Error())
}
示例4: TestGetServerSecurityGroups
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])
}
示例5: TestEndpoints
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)
}
示例6: TestServiceURLNetworkV3Returns
func TestServiceURLNetworkV3Returns(t *testing.T) {
sc := []service{createService("network", "neutron", testEndpoints...)}
url, err := getAppendVersionServiceURL("t", nil, sc, "network", "region2", "3")
testUtil.IsNil(t, err)
testUtil.Equals(t, "http://endpoint2/v3", url)
}
示例7: TestServiceURLComputeV3Returns
func TestServiceURLComputeV3Returns(t *testing.T) {
sc := []service{createService("computev3", "nova", testEndpoints...)}
url, err := getComputeServiceURL("t", nil, sc, "compute", "region1", "3")
testUtil.IsNil(t, err)
testUtil.Equals(t, "http://endpoint1", url)
}
示例8: TestPrivateCloudImagesDetail
func TestPrivateCloudImagesDetail(t *testing.T) {
// Read private cloud response content from file
imagesTestFilePath := "./testdata/private_cloud_images_detail.json"
imagesTestFileContent, err := ioutil.ReadFile(imagesTestFilePath)
if err != nil {
t.Error(fmt.Errorf("Failed to read JSON file %s: '%s'", imagesTestFilePath, err.Error()))
}
// Decode the content
sampleImgs := imagesDetailResponse{}
err = json.Unmarshal(imagesTestFileContent, &sampleImgs)
if err != nil {
t.Error(fmt.Errorf("Failed to decode JSON file %s: '%s'", imagesTestFilePath, err.Error()))
}
// Test the SDK API imageService.ImagesDetail()
anon := func(imageService *image.Service) {
images, err := imageService.ImagesDetail()
if err != nil {
t.Error(err)
}
if len(images) != len(sampleImgs.Images) {
t.Error(errors.New("Incorrect number of images found"))
}
// Verify returned images match original sample images
testUtil.Equals(t, sampleImgs.Images, images)
}
testImageServiceAction(t, "images/detail?limit=21", string(imagesTestFileContent), anon)
}
示例9: TestListObjects
func TestListObjects(t *testing.T) {
var objList = `[
{"name":"test obj 1",
"hash":"4281c348eaf83e70ddce0e07221c3d28",
"bytes":14,
"content_type":"application\/octet-stream",
"last_modified":"2009-02-03T05:26:32.612278"},
{"name":"test obj 2",
"hash":"b039efe731ad111bc1b0ef221c3849d0",
"bytes":64,
"content_type":"application\/octet-stream",
"last_modified":"2009-02-03T05:26:32.612278"}
]`
var apiServer = httptest.NewServer(http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(200)
w.Write([]byte(objList))
return
}
t.Error(errors.New("Failed: r.Method == GET"))
}))
defer apiServer.Close()
myList, err := objectstorage.ListObjects(
0, "", "", "", "", apiServer.URL+containerPrefix, tokn)
if err != nil {
t.Error(err)
}
testUtil.Equals(t, objList, string(myList))
}
示例10: TestGetFlavorsDetail
func TestGetFlavorsDetail(t *testing.T) {
mockResponseObject := FlavorsDetailContainer{
FlavorsDetail: []FlavorDetail{sampleFlavorDetail, sampleFlavorDetail2}}
apiServer := testUtil.CreateGetJSONTestRequestServerWithMockObject(t, tokn, mockResponseObject, "/flavors/detail?limit=21")
defer apiServer.Close()
service := CreateComputeService(apiServer.URL)
flavorsDetail, err := service.FlavorsDetail()
testUtil.IsNil(t, err)
if len(flavorsDetail) != 2 {
t.Error(errors.New("Error: Expected 2 flavors detail to be listed"))
}
testUtil.Equals(t, sampleFlavorDetail, flavorsDetail[0])
testUtil.Equals(t, sampleFlavorDetail2, flavorsDetail[1])
}
示例11: TestCompabilitySecurityGroupPayloads
func TestCompabilitySecurityGroupPayloads(t *testing.T) {
// Read private cloud response content from file
securityGroupsTestFilePath := "./testdata/securitygroup_test_sgs.json"
securityGroupsTestFileContent, err := ioutil.ReadFile(securityGroupsTestFilePath)
if err != nil {
t.Error(fmt.Errorf("Failed to read JSON file %s: '%s'", securityGroupsTestFilePath, err.Error()))
}
// Decode the content
sampleSGs := compute.SecurityGroupsContainer{}
err = json.Unmarshal(securityGroupsTestFileContent, &sampleSGs)
if err != nil {
t.Error(fmt.Errorf("Failed to decode JSON file %s: '%s'", securityGroupsTestFilePath, err.Error()))
}
// Test the SDK API computeService.SecurityGroups()
anon := func(computeService *compute.Service) {
securityGroups, err := computeService.SecurityGroups()
if err != nil {
t.Error(err)
}
if len(securityGroups) != len(sampleSGs.SecurityGroups) {
t.Error(errors.New("Incorrect number of securityGroups found"))
}
// Verify returned availability zones match original sample availability zones
testUtil.Equals(t, sampleSGs.SecurityGroups, securityGroups)
}
testComputeServiceAction(t, "os-security-groups", string(securityGroupsTestFileContent), anon)
}
示例12: TestCreateServer
func TestCreateServer(t *testing.T) {
apiServer := testUtil.CreatePostJSONTestRequestServer(t, tokn, createServerJSONPayload, "servers",
`{"server":{"name":"my_server","imageRef":"8c3cd338-1282-4fbb-bbaf-2256ff97c7b7","key_name":"my_key_name","flavorRef":"101","maxcount":1,"mincount":1,"user_data":"my_user_data","availability_zone":"az1","networks":[{"uuid":"1111d337-0282-4fbb-bbaf-2256ff97c7b7","port":"881"}],"security_groups":[{"name":"my_security_group_123"}]}}`)
defer apiServer.Close()
serverService := CreateComputeService(apiServer.URL)
az := "az1"
userData := "my_user_data"
maxMinCount := int32(1)
var serverCreationParameters = ServerCreationParameters{
Name: "my_server",
ImageRef: "8c3cd338-1282-4fbb-bbaf-2256ff97c7b7",
KeyPairName: "my_key_name",
FlavorRef: "101",
MaxCount: &maxMinCount,
MinCount: &maxMinCount,
AvailabilityZone: &az,
UserData: &userData,
Networks: []ServerNetworkParameters{ServerNetworkParameters{UUID: "1111d337-0282-4fbb-bbaf-2256ff97c7b7", Port: "881"}},
SecurityGroups: []SecurityGroup{SecurityGroup{Name: "my_security_group_123"}}}
result, err := serverService.CreateServer(serverCreationParameters)
testUtil.IsNil(t, err)
testUtil.Equals(t, createServerResponse, result)
}
示例13: TestGetSelfLinkNotFoundNoErrorOccurs
func TestGetSelfLinkNotFoundNoErrorOccurs(t *testing.T) {
v := Version{Status: "CURRENT",
ID: "ID",
Links: []Link{Link{HRef: "http://doc", Rel: "decribedby"}}}
foundLink := v.GetSelfLink()
testUtil.Equals(t, foundLink.HRef, "")
}
示例14: TestPrivateCloudAvailabilityZones
func TestPrivateCloudAvailabilityZones(t *testing.T) {
// Read private cloud response content from file
availabilityZonesTestFilePath := "./testdata/availabilityzone_test_azs.json"
availabilityZonesTestFileContent, err := ioutil.ReadFile(availabilityZonesTestFilePath)
if err != nil {
t.Error(fmt.Errorf("Failed to read JSON file %s: '%s'", availabilityZonesTestFilePath, err.Error()))
}
// Decode the content
sampleAzs := compute.AvailabilityZonesContainer{}
err = json.Unmarshal(availabilityZonesTestFileContent, &sampleAzs)
if err != nil {
t.Error(fmt.Errorf("Failed to decode JSON file %s: '%s'", availabilityZonesTestFilePath, err.Error()))
}
// Test the SDK API computeService.AvailabilityZones()
anon := func(computeService *compute.Service) {
availabilityZones, err := computeService.AvailabilityZones()
if err != nil {
t.Error(err)
}
if len(availabilityZones) != len(sampleAzs.AvailabilityZones) {
t.Error(errors.New("Incorrect number of availabilityZones found"))
}
// Verify returned availability zones match original sample availability zones
testUtil.Equals(t, sampleAzs.AvailabilityZones, availabilityZones)
}
testComputeServiceAction(t, "os-availability-zone", string(availabilityZonesTestFileContent), anon)
}
示例15: TestFindEndpointVersionNoValueFoundNoErrorShouldOccur
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)
}