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

Golang v1.C类代码示例

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

本文整理汇总了Golang中github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/gopkg/in/check/v1.C的典型用法代码示例。如果您正苦于以下问题:Golang C类的具体用法?Golang C怎么用?Golang C使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: TestGetBlobRange

func (s *StorageBlobSuite) TestGetBlobRange(c *chk.C) {
	cnt := randContainer()
	blob := randString(20)
	body := "0123456789"

	cli := getBlobClient(c)
	c.Assert(cli.CreateContainer(cnt, ContainerAccessTypeBlob), chk.IsNil)
	defer cli.DeleteContainer(cnt)

	c.Assert(cli.putSingleBlockBlob(cnt, blob, []byte(body)), chk.IsNil)
	defer cli.DeleteBlob(cnt, blob)

	// Read 1-3
	for _, r := range []struct {
		rangeStr string
		expected string
	}{
		{"0-", body},
		{"1-3", body[1 : 3+1]},
		{"3-", body[3:]},
	} {
		resp, err := cli.GetBlobRange(cnt, blob, r.rangeStr)
		c.Assert(err, chk.IsNil)
		blobBody, err := ioutil.ReadAll(resp)
		c.Assert(err, chk.IsNil)

		str := string(blobBody)
		c.Assert(str, chk.Equals, r.expected)
	}
}
开发者ID:gilbertchen,项目名称:azure-sdk-for-go,代码行数:30,代码来源:blob_test.go


示例2: TestGetBlobSASURI

func (s *StorageBlobSuite) TestGetBlobSASURI(c *chk.C) {
	api, err := NewClient("foo", "YmFy", DefaultBaseURL, "2013-08-15", true)
	c.Assert(err, chk.IsNil)
	cli := api.GetBlobService()
	expiry := time.Time{}

	expectedParts := url.URL{
		Scheme: "https",
		Host:   "foo.blob.core.windows.net",
		Path:   "container/name",
		RawQuery: url.Values{
			"sv":  {"2013-08-15"},
			"sig": {"/OXG7rWh08jYwtU03GzJM0DHZtidRGpC6g69rSGm3I0="},
			"sr":  {"b"},
			"sp":  {"r"},
			"se":  {"0001-01-01T00:00:00Z"},
		}.Encode()}

	u, err := cli.GetBlobSASURI("container", "name", expiry, "r")
	c.Assert(err, chk.IsNil)
	sasParts, err := url.Parse(u)
	c.Assert(err, chk.IsNil)
	c.Assert(expectedParts.String(), chk.Equals, sasParts.String())
	c.Assert(expectedParts.Query(), chk.DeepEquals, sasParts.Query())
}
开发者ID:gilbertchen,项目名称:azure-sdk-for-go,代码行数:25,代码来源:blob_test.go


示例3: TestGetEndpoint_Mixed

func (s *StorageClientSuite) TestGetEndpoint_Mixed(c *chk.C) {
	cli, err := NewBasicClient("foo", "YmFy")
	c.Assert(err, chk.IsNil)
	params := url.Values{}
	params.Set("a", "b")
	params.Set("c", "d")
	output := cli.getEndpoint(blobServiceName, "path", params)
	c.Assert(output, chk.Equals, "https://foo.blob.core.windows.net/path?a=b&c=d")
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:9,代码来源:client_test.go


示例4: Test_prepareBlockListRequest

func (s *StorageClientSuite) Test_prepareBlockListRequest(c *chk.C) {
	empty := []Block{}
	expected := `<?xml version="1.0" encoding="utf-8"?><BlockList></BlockList>`
	c.Assert(prepareBlockListRequest(empty), chk.DeepEquals, expected)

	blocks := []Block{{"foo", BlockStatusLatest}, {"bar", BlockStatusUncommitted}}
	expected = `<?xml version="1.0" encoding="utf-8"?><BlockList><Latest>foo</Latest><Uncommitted>bar</Uncommitted></BlockList>`
	c.Assert(prepareBlockListRequest(blocks), chk.DeepEquals, expected)
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:9,代码来源:util_test.go


示例5: Test_createAuthorizationHeader

func (s *StorageClientSuite) Test_createAuthorizationHeader(c *chk.C) {
	key := base64.StdEncoding.EncodeToString([]byte("bar"))
	cli, err := NewBasicClient("foo", key)
	c.Assert(err, chk.IsNil)

	canonicalizedString := `foobarzoo`
	expected := `SharedKey foo:h5U0ATVX6SpbFX1H6GNuxIMeXXCILLoIvhflPtuQZ30=`
	c.Assert(cli.createAuthorizationHeader(canonicalizedString), chk.Equals, expected)
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:9,代码来源:client_test.go


示例6: Test_xmlUnmarshal

func (s *StorageClientSuite) Test_xmlUnmarshal(c *chk.C) {
	xml := `<?xml version="1.0" encoding="utf-8"?>
	<Blob>
		<Name>myblob</Name>
	</Blob>`
	var blob Blob
	body := ioutil.NopCloser(strings.NewReader(xml))
	c.Assert(xmlUnmarshal(body, &blob), chk.IsNil)
	c.Assert(blob.Name, chk.Equals, "myblob")
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:10,代码来源:util_test.go


示例7: TestReturnsStorageServiceError

func (s *StorageClientSuite) TestReturnsStorageServiceError(c *chk.C) {
	// attempt to delete a nonexisting container
	_, err := getBlobClient(c).deleteContainer(randContainer())
	c.Assert(err, chk.NotNil)

	v, ok := err.(AzureStorageServiceError)
	c.Check(ok, chk.Equals, true)
	c.Assert(v.StatusCode, chk.Equals, 404)
	c.Assert(v.Code, chk.Equals, "ContainerNotFound")
	c.Assert(v.Code, chk.Not(chk.Equals), "")
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:11,代码来源:client_test.go


示例8: TestPutBlock

func (s *StorageBlobSuite) TestPutBlock(c *chk.C) {
	cli := getBlobClient(c)
	cnt := randContainer()
	c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
	defer cli.deleteContainer(cnt)

	blob := randString(20)
	chunk := []byte(randString(1024))
	blockID := base64.StdEncoding.EncodeToString([]byte("foo"))
	c.Assert(cli.PutBlock(cnt, blob, blockID, chunk), chk.IsNil)
}
开发者ID:gilbertchen,项目名称:azure-sdk-for-go,代码行数:11,代码来源:blob_test.go


示例9: TestPostMessage_PeekMessage_DeleteMessage

func (s *StorageQueueSuite) TestPostMessage_PeekMessage_DeleteMessage(c *chk.C) {
	q := randString(20)
	cli := getQueueClient(c)
	c.Assert(cli.CreateQueue(q), chk.IsNil)
	defer cli.DeleteQueue(q)

	msg := randString(64 * 1024) // exercise max length
	c.Assert(cli.PutMessage(q, msg, PutMessageParameters{}), chk.IsNil)
	r, err := cli.PeekMessages(q, PeekMessagesParameters{})
	c.Assert(err, chk.IsNil)
	c.Assert(len(r.QueueMessagesList), chk.Equals, 1)
	c.Assert(r.QueueMessagesList[0].MessageText, chk.Equals, msg)
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:13,代码来源:queue_test.go


示例10: TestDeleteMessages

func (s *StorageQueueSuite) TestDeleteMessages(c *chk.C) {
	q := randString(20)
	cli := getQueueClient(c)
	c.Assert(cli.CreateQueue(q), chk.IsNil)
	defer cli.DeleteQueue(q)

	c.Assert(cli.PutMessage(q, "message", PutMessageParameters{}), chk.IsNil)
	r, err := cli.GetMessages(q, GetMessagesParameters{VisibilityTimeout: 1})
	c.Assert(err, chk.IsNil)
	c.Assert(len(r.QueueMessagesList), chk.Equals, 1)
	m := r.QueueMessagesList[0]
	c.Assert(cli.DeleteMessage(q, m.MessageID, m.PopReceipt), chk.IsNil)
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:13,代码来源:queue_test.go


示例11: TestGetBaseURL_Basic_Https

func (s *StorageClientSuite) TestGetBaseURL_Basic_Https(c *chk.C) {
	cli, err := NewBasicClient("foo", "YmFy")
	c.Assert(err, chk.IsNil)
	c.Assert(cli.apiVersion, chk.Equals, DefaultAPIVersion)
	c.Assert(err, chk.IsNil)
	c.Assert(cli.getBaseURL("table"), chk.Equals, "https://foo.table.core.windows.net")
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:7,代码来源:client_test.go


示例12: TestContainerExists

func (s *StorageBlobSuite) TestContainerExists(c *chk.C) {
	cnt := randContainer()
	cli := getBlobClient(c)
	ok, err := cli.ContainerExists(cnt)
	c.Assert(err, chk.IsNil)
	c.Assert(ok, chk.Equals, false)

	c.Assert(cli.CreateContainer(cnt, ContainerAccessTypeBlob), chk.IsNil)
	defer cli.DeleteContainer(cnt)

	ok, err = cli.ContainerExists(cnt)
	c.Assert(err, chk.IsNil)
	c.Assert(ok, chk.Equals, true)
}
开发者ID:gilbertchen,项目名称:azure-sdk-for-go,代码行数:14,代码来源:blob_test.go


示例13: TestQueueExists

func (s *StorageQueueSuite) TestQueueExists(c *chk.C) {
	cli := getQueueClient(c)
	ok, err := cli.QueueExists("nonexistent-queue")
	c.Assert(err, chk.IsNil)
	c.Assert(ok, chk.Equals, false)

	name := randString(20)
	c.Assert(cli.CreateQueue(name), chk.IsNil)
	defer cli.DeleteQueue(name)

	ok, err = cli.QueueExists(name)
	c.Assert(err, chk.IsNil)
	c.Assert(ok, chk.Equals, true)
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:14,代码来源:queue_test.go


示例14: TestCreateBlockBlob

func (s *StorageBlobSuite) TestCreateBlockBlob(c *chk.C) {
	cli := getBlobClient(c)
	cnt := randContainer()
	c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
	defer cli.deleteContainer(cnt)

	blob := randString(20)
	c.Assert(cli.CreateBlockBlob(cnt, blob), chk.IsNil)

	// Verify
	blocks, err := cli.GetBlockList(cnt, blob, BlockListTypeAll)
	c.Assert(err, chk.IsNil)
	c.Assert(len(blocks.CommittedBlocks), chk.Equals, 0)
	c.Assert(len(blocks.UncommittedBlocks), chk.Equals, 0)
}
开发者ID:gilbertchen,项目名称:azure-sdk-for-go,代码行数:15,代码来源:blob_test.go


示例15: TestPutPageBlob

func (s *StorageBlobSuite) TestPutPageBlob(c *chk.C) {
	cli := getBlobClient(c)
	cnt := randContainer()
	c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
	defer cli.deleteContainer(cnt)

	blob := randString(20)
	size := int64(10 * 1024 * 1024)
	c.Assert(cli.PutPageBlob(cnt, blob, size, nil), chk.IsNil)

	// Verify
	props, err := cli.GetBlobProperties(cnt, blob)
	c.Assert(err, chk.IsNil)
	c.Assert(props.ContentLength, chk.Equals, size)
	c.Assert(props.BlobType, chk.Equals, BlobTypePage)
}
开发者ID:gilbertchen,项目名称:azure-sdk-for-go,代码行数:16,代码来源:blob_test.go


示例16: TestDeleteShareIfNotExists

func (s *StorageFileSuite) TestDeleteShareIfNotExists(c *chk.C) {
	cli := getFileClient(c)
	name := randShare()

	// delete non-existing share
	ok, err := cli.DeleteShareIfExists(name)
	c.Assert(err, chk.IsNil)
	c.Assert(ok, chk.Equals, false)

	c.Assert(cli.CreateShare(name), chk.IsNil)

	// delete existing share
	ok, err = cli.DeleteShareIfExists(name)
	c.Assert(err, chk.IsNil)
	c.Assert(ok, chk.Equals, true)
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:16,代码来源:file_test.go


示例17: TestGetBlobURL

func (s *StorageBlobSuite) TestGetBlobURL(c *chk.C) {
	api, err := NewBasicClient("foo", "YmFy")
	c.Assert(err, chk.IsNil)
	cli := api.GetBlobService()

	c.Assert(cli.GetBlobURL("c", "nested/blob"), chk.Equals, "https://foo.blob.core.windows.net/c/nested/blob")
	c.Assert(cli.GetBlobURL("", "blob"), chk.Equals, "https://foo.blob.core.windows.net/$root/blob")
	c.Assert(cli.GetBlobURL("", "nested/blob"), chk.Equals, "https://foo.blob.core.windows.net/$root/nested/blob")
}
开发者ID:gilbertchen,项目名称:azure-sdk-for-go,代码行数:9,代码来源:blob_test.go


示例18: Test_SetMetadataGetMetadata_Roundtrips

func (s *StorageQueueSuite) Test_SetMetadataGetMetadata_Roundtrips(c *chk.C) {
	cli := getQueueClient(c)
	name := randString(20)
	c.Assert(cli.CreateQueue(name), chk.IsNil)
	defer cli.DeleteQueue(name)

	metadata := make(map[string]string)
	metadata["Foo1"] = "bar1"
	metadata["fooBaz"] = "bar"
	err := cli.SetMetadata(name, metadata)
	c.Assert(err, chk.IsNil)

	qm, err := cli.GetMetadata(name)
	c.Assert(err, chk.IsNil)
	c.Assert(qm.UserDefinedMetadata["foo1"], chk.Equals, "bar1")
	c.Assert(qm.UserDefinedMetadata["foobaz"], chk.Equals, "bar")
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:17,代码来源:queue_test.go


示例19: TestCreateBlockBlobFromReader

func (s *StorageBlobSuite) TestCreateBlockBlobFromReader(c *chk.C) {
	cli := getBlobClient(c)
	cnt := randContainer()
	c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
	defer cli.deleteContainer(cnt)

	name := randString(20)
	data := randBytes(8888)
	c.Assert(cli.CreateBlockBlobFromReader(cnt, name, uint64(len(data)), bytes.NewReader(data), nil), chk.IsNil)

	body, err := cli.GetBlob(cnt, name)
	c.Assert(err, chk.IsNil)
	gotData, err := ioutil.ReadAll(body)
	body.Close()

	c.Assert(err, chk.IsNil)
	c.Assert(gotData, chk.DeepEquals, data)
}
开发者ID:gilbertchen,项目名称:azure-sdk-for-go,代码行数:18,代码来源:blob_test.go


示例20: Test_getStandardHeaders

func (s *StorageClientSuite) Test_getStandardHeaders(c *chk.C) {
	cli, err := NewBasicClient("foo", "YmFy")
	c.Assert(err, chk.IsNil)

	headers := cli.getStandardHeaders()
	c.Assert(len(headers), chk.Equals, 2)
	c.Assert(headers["x-ms-version"], chk.Equals, cli.apiVersion)
	if _, ok := headers["x-ms-date"]; !ok {
		c.Fatal("Missing date header")
	}
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:11,代码来源:client_test.go



注:本文中的github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/gopkg/in/check/v1.C类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang management.IsResourceNotFoundError函数代码示例发布时间:2022-05-24
下一篇:
Golang to.StringPtr函数代码示例发布时间: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