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

Golang testhelper.CheckEquals函数代码示例

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

本文整理汇总了Golang中github.com/rackspace/rack/internal/github.com/rackspace/gophercloud/testhelper.CheckEquals函数的典型用法代码示例。如果您正苦于以下问题:Golang CheckEquals函数的具体用法?Golang CheckEquals怎么用?Golang CheckEquals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CheckEquals函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestCreateContainer

func TestCreateContainer(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	HandleCreateContainerSuccessfully(t)

	options := CreateOpts{ContentType: "application/json", Metadata: map[string]string{"foo": "bar"}}
	res := Create(fake.ServiceClient(), "testContainer", options)
	c, err := res.Extract()
	th.CheckNoErr(t, err)
	th.CheckEquals(t, "bar", res.Header["X-Container-Meta-Foo"][0])
	th.CheckEquals(t, "1234567", c.TransID)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:12,代码来源:requests_test.go


示例2: TestCreateURL

func TestCreateURL(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	c := client.ServiceClient()

	th.CheckEquals(t, c.Endpoint+"os-volumes_boot", createURL(c))
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:7,代码来源:urls_test.go


示例3: TestListImageDetails

func TestListImageDetails(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()

	th.Mux.HandleFunc("/images/detail", func(w http.ResponseWriter, r *http.Request) {
		th.TestMethod(t, r, "GET")
		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)

		w.Header().Add("Content-Type", "application/json")
		r.ParseForm()
		marker := r.Form.Get("marker")
		switch marker {
		case "":
			fmt.Fprintf(w, ListOutput)
		case "e19a734c-c7e6-443a-830c-242209c4d65d":
			fmt.Fprintf(w, `{ "images": [] }`)
		default:
			t.Fatalf("Unexpected marker: [%s]", marker)
		}
	})

	count := 0
	err := ListDetail(client.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
		count++
		actual, err := ExtractImages(page)
		th.AssertNoErr(t, err)
		th.CheckDeepEquals(t, ExpectedImageSlice, actual)

		return true, nil
	})
	th.AssertNoErr(t, err)
	th.CheckEquals(t, 1, count)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:33,代码来源:delegate_test.go


示例4: TestDeleteURL

func TestDeleteURL(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	c := client.ServiceClient()

	th.CheckEquals(t, c.Endpoint+"os-keypairs/wat", deleteURL(c, "wat"))
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:7,代码来源:urls_test.go


示例5: TestListURL

func TestListURL(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	c := client.ServiceClient()

	th.CheckEquals(t, c.Endpoint+"os-keypairs", listURL(c))
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:7,代码来源:urls_test.go


示例6: TestV2EndpointNone

func TestV2EndpointNone(t *testing.T) {
	_, err := V2EndpointURL(&catalog2, gophercloud.EndpointOpts{
		Type:         "nope",
		Availability: gophercloud.AvailabilityPublic,
	})
	th.CheckEquals(t, ErrEndpointNotFound{}.Error(), err.Error())
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:7,代码来源:endpoint_location_test.go


示例7: TestAuthenticatedClientV2

func TestAuthenticatedClientV2(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()

	th.Mux.HandleFunc("/v2.0/tokens", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, `
      {
        "access": {
          "token": {
            "id": "01234567890",
            "expires": "2014-10-01T10:00:00.000000Z"
          },
          "serviceCatalog": []
        }
      }
    `)
	})

	options := gophercloud.AuthOptions{
		Username:         "me",
		APIKey:           "09876543210",
		IdentityEndpoint: th.Endpoint() + "v2.0/",
	}
	client, err := AuthenticatedClient(options)
	th.AssertNoErr(t, err)
	th.CheckEquals(t, "01234567890", client.TokenID)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:27,代码来源:client_test.go


示例8: TestUserAgent

func TestUserAgent(t *testing.T) {
	p := &ProviderClient{}

	p.UserAgent.Prepend("custom-user-agent/2.4.0")
	expected := "custom-user-agent/2.4.0 gophercloud/1.0.0"
	actual := p.UserAgent.Join()
	th.CheckEquals(t, expected, actual)

	p.UserAgent.Prepend("another-custom-user-agent/0.3.0", "a-third-ua/5.9.0")
	expected = "another-custom-user-agent/0.3.0 a-third-ua/5.9.0 custom-user-agent/2.4.0 gophercloud/1.0.0"
	actual = p.UserAgent.Join()
	th.CheckEquals(t, expected, actual)

	p.UserAgent = UserAgent{}
	expected = "gophercloud/1.0.0"
	actual = p.UserAgent.Join()
	th.CheckEquals(t, expected, actual)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:18,代码来源:provider_client_test.go


示例9: TestExtractList

func TestExtractList(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	servers.HandleServerListSuccessfully(t)

	pages := 0
	err := servers.List(client.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
		pages++

		config, err := ExtractDiskConfig(page, 0)
		th.AssertNoErr(t, err)
		th.CheckEquals(t, Manual, *config)

		return true, nil
	})
	th.AssertNoErr(t, err)
	th.CheckEquals(t, pages, 1)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:18,代码来源:results_test.go


示例10: TestV3EndpointBadAvailability

func TestV3EndpointBadAvailability(t *testing.T) {
	_, err := V3EndpointURL(&catalog3, gophercloud.EndpointOpts{
		Type:         "same",
		Name:         "same",
		Region:       "same",
		Availability: "wat",
	})
	th.CheckEquals(t, "Unexpected availability in endpoint query", err.Error())
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:9,代码来源:endpoint_location_test.go


示例11: TestExtractGet

func TestExtractGet(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	servers.HandleServerGetSuccessfully(t)

	config, err := ExtractGet(servers.Get(client.ServiceClient(), "1234asdf"))
	th.AssertNoErr(t, err)
	th.CheckEquals(t, Manual, *config)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:9,代码来源:results_test.go


示例12: TestDownloadObject

func TestDownloadObject(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	os.HandleDownloadObjectSuccessfully(t)

	content, err := Download(fake.ServiceClient(), "testContainer", "testObject", nil).ExtractContent()
	th.AssertNoErr(t, err)
	th.CheckEquals(t, string(content), "Successful download with Gophercloud")
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:9,代码来源:delegate_test.go


示例13: TestUpdate

func TestUpdate(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()

	MockUpdateResponse(t)

	options := UpdateOpts{Name: "vol-002"}
	v, err := Update(client.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22", options).Extract()
	th.AssertNoErr(t, err)
	th.CheckEquals(t, "vol-002", v.Name)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:11,代码来源:requests_test.go


示例14: TestExtractUpdate

func TestExtractUpdate(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	servers.HandleServerUpdateSuccessfully(t)

	r := servers.Update(client.ServiceClient(), "1234asdf", servers.UpdateOpts{
		Name: "new-name",
	})
	config, err := ExtractUpdate(r)
	th.AssertNoErr(t, err)
	th.CheckEquals(t, Manual, *config)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:12,代码来源:results_test.go


示例15: TestDownloadExtraction

func TestDownloadExtraction(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	HandleDownloadObjectSuccessfully(t)

	response := Download(fake.ServiceClient(), "testContainer", "testObject", nil)

	// Check []byte extraction
	bytes, err := response.ExtractContent()
	th.AssertNoErr(t, err)
	th.CheckEquals(t, "Successful download with Gophercloud", string(bytes))
}
开发者ID:nelsnelson,项目名称:rack,代码行数:12,代码来源:requests_test.go


示例16: TestDownloadReader

func TestDownloadReader(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	HandleDownloadObjectSuccessfully(t)

	response := Download(fake.ServiceClient(), "testContainer", "testObject", nil)
	defer response.Body.Close()

	// Check reader
	buf := bytes.NewBuffer(make([]byte, 0))
	io.CopyN(buf, response.Body, 10)
	th.CheckEquals(t, "Successful", string(buf.Bytes()))
}
开发者ID:nelsnelson,项目名称:rack,代码行数:13,代码来源:requests_test.go


示例17: TestNextPageURL

func TestNextPageURL(t *testing.T) {
	var page ImagePage
	var body map[string]interface{}
	bodyString := []byte(`{"images":{"links":[{"href":"http://192.154.23.87/12345/images/image3","rel":"bookmark"}]}, "images_links":[{"href":"http://192.154.23.87/12345/images/image4","rel":"next"}]}`)
	err := json.Unmarshal(bodyString, &body)
	if err != nil {
		t.Fatalf("Error unmarshaling data into page body: %v", err)
	}
	page.Body = body

	expected := "http://192.154.23.87/12345/images/image4"
	actual, err := page.NextPageURL()
	th.AssertNoErr(t, err)
	th.CheckEquals(t, expected, actual)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:15,代码来源:requests_test.go


示例18: TestExtractRebuild

func TestExtractRebuild(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	servers.HandleRebuildSuccessfully(t, servers.SingleServerBody)

	r := servers.Rebuild(client.ServiceClient(), "1234asdf", servers.RebuildOpts{
		Name:       "new-name",
		AdminPass:  "swordfish",
		ImageID:    "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/images/f90f6034-2570-4974-8351-6b49732ef2eb",
		AccessIPv4: "1.2.3.4",
	})
	config, err := ExtractRebuild(r)
	th.AssertNoErr(t, err)
	th.CheckEquals(t, Manual, *config)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:15,代码来源:results_test.go


示例19: TestAuthenticatedClientV3

func TestAuthenticatedClientV3(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()

	const ID = "0123456789"

	th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, `
			{
				"versions": {
					"values": [
						{
							"status": "stable",
							"id": "v3.0",
							"links": [
								{ "href": "%s", "rel": "self" }
							]
						},
						{
							"status": "stable",
							"id": "v2.0",
							"links": [
								{ "href": "%s", "rel": "self" }
							]
						}
					]
				}
			}
		`, th.Endpoint()+"v3/", th.Endpoint()+"v2.0/")
	})

	th.Mux.HandleFunc("/v3/auth/tokens", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Add("X-Subject-Token", ID)

		w.WriteHeader(http.StatusCreated)
		fmt.Fprintf(w, `{ "token": { "expires_at": "2013-02-02T18:30:59.000000Z" } }`)
	})

	options := gophercloud.AuthOptions{
		UserID:           "me",
		Password:         "secret",
		IdentityEndpoint: th.Endpoint(),
	}
	client, err := AuthenticatedClient(options)
	th.AssertNoErr(t, err)
	th.CheckEquals(t, ID, client.TokenID)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:47,代码来源:client_test.go


示例20: TestEnumerateSinglePaged

func TestEnumerateSinglePaged(t *testing.T) {
	callCount := 0
	pager := setupSinglePaged()
	defer testhelper.TeardownHTTP()

	err := pager.EachPage(func(page Page) (bool, error) {
		callCount++

		expected := []int{1, 2, 3}
		actual, err := ExtractSingleInts(page)
		testhelper.AssertNoErr(t, err)
		testhelper.CheckDeepEquals(t, expected, actual)
		return true, nil
	})
	testhelper.CheckNoErr(t, err)
	testhelper.CheckEquals(t, 1, callCount)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:17,代码来源:single_test.go



注:本文中的github.com/rackspace/rack/internal/github.com/rackspace/gophercloud/testhelper.CheckEquals函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang testhelper.SetupHTTP函数代码示例发布时间:2022-05-28
下一篇:
Golang testhelper.CheckDeepEquals函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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