• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang testUtil.Equals函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中git/openstack/org/stackforge/golang-client/git/testUtil.Equals函数的典型用法代码示例。如果您正苦于以下问题:Golang Equals函数的具体用法?Golang Equals怎么用?Golang Equals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Equals函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:25,代码来源:limits_test.go


示例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())
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:8,代码来源:authServiceCatalogResolvingFunctions_test.go


示例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())
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:9,代码来源:authServiceCatalogResolvingFunctions_test.go


示例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])
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:10,代码来源:securitygroup_test.go


示例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)
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:15,代码来源:serviceversionlist_test.go


示例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)
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:7,代码来源:authServiceCatalogResolvingFunctions_test.go


示例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)
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:7,代码来源:authServiceCatalogResolvingFunctions_test.go


示例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)
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:32,代码来源:image_test.go


示例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))
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:32,代码来源:objectstorage_test.go


示例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])
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:16,代码来源:flavor_test.go


示例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)
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:33,代码来源:securitygroup_test.go


示例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)
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:26,代码来源:server_test.go


示例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, "")
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:7,代码来源:serviceversionlist_test.go


示例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)
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:34,代码来源:availabilityzone_test.go


示例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)
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:8,代码来源:serviceversionlist_test.go


示例16: TestFindEndpointVersionValid

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)
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:8,代码来源:serviceversionlist_test.go


示例17: TestDefaultServiceURLFoundInCatalogFoundInVersionList

func TestDefaultServiceURLFoundInCatalogFoundInVersionList(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", "1")
	testUtil.IsNil(t, err)
	testUtil.Equals(t, "http://region-b.geo-1.image.hpcloudsvc.com/v1/", url)
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:8,代码来源:authServiceCatalogResolvingFunctions_test.go


示例18: TestGetVolumeType

func TestGetVolumeType(t *testing.T) {
	apiServer := testUtil.CreateGetJSONTestRequestServerVerifyStatusAndURL(t, tokn, 200, sampleVolumeTypeJson, "/types/id")
	defer apiServer.Close()

	service := CreateVolumeService(apiServer.URL)
	volume, err := service.VolumeType("id")
	testUtil.IsNil(t, err)
	testUtil.Equals(t, volumeTypeSample, volume)
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:9,代码来源:volumetype_test.go


示例19: TestGetFlavors

func TestGetFlavors(t *testing.T) {

	mockResponseObject := FlavorsContainer{
		Flavors: []Flavor{sampleFlavor, sampleFlavor2}}

	apiServer := testUtil.CreateGetJSONTestRequestServerWithMockObject(t, tokn, mockResponseObject, "/flavors")
	defer apiServer.Close()

	service := CreateDatabaseService(apiServer.URL)
	flavors, err := service.Flavors()
	testUtil.IsNil(t, err)

	if len(flavors) != 2 {
		t.Error(errors.New("Error: Expected 2 flavors to be listed"))
	}
	testUtil.Equals(t, sampleFlavor, flavors[0])
	testUtil.Equals(t, sampleFlavor2, flavors[1])
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:18,代码来源:flavor_test.go


示例20: TestGetSecurityGroup

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)
}
开发者ID:alvaropeon,项目名称:hpcloud-kubesetup,代码行数:9,代码来源:securitygroup_test.go



注:本文中的git/openstack/org/stackforge/golang-client/git/testUtil.Equals函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang testUtil.IsNil函数代码示例发布时间:2022-05-24
下一篇:
Golang openstack.Session类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap