当前位置: 首页>>代码示例>>Golang>>正文


Golang v1.C类代码示例

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


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


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