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


Golang C.Assert方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: TestListContainersPagination

func (s *StorageBlobSuite) TestListContainersPagination(c *chk.C) {
	cli := getBlobClient(c)
	c.Assert(deleteTestContainers(cli), chk.IsNil)

	const n = 5
	const pageSize = 2

	// Create test containers
	created := []string{}
	for i := 0; i < n; i++ {
		name := randContainer()
		c.Assert(cli.CreateContainer(name, ContainerAccessTypePrivate), chk.IsNil)
		created = append(created, name)
	}
	sort.Strings(created)

	// Defer test container deletions
	defer func() {
		var wg sync.WaitGroup
		for _, cnt := range created {
			wg.Add(1)
			go func(name string) {
				c.Assert(cli.DeleteContainer(name), chk.IsNil)
				wg.Done()
			}(cnt)
		}
		wg.Wait()
	}()

	// Paginate results
	seen := []string{}
	marker := ""
	for {
		resp, err := cli.ListContainers(ListContainersParameters{
			Prefix:     testContainerPrefix,
			MaxResults: pageSize,
			Marker:     marker})
		c.Assert(err, chk.IsNil)

		containers := resp.Containers
		if len(containers) > pageSize {
			c.Fatalf("Got a bigger page. Expected: %d, got: %d", pageSize, len(containers))
		}

		for _, c := range containers {
			seen = append(seen, c.Name)
		}

		marker = resp.NextMarker
		if marker == "" || len(containers) == 0 {
			break
		}
	}

	c.Assert(seen, chk.DeepEquals, created)
}
开发者ID:gilbertchen,项目名称:azure-sdk-for-go,代码行数:56,代码来源:blob_test.go

示例7: 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

示例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: getBasicClient

// getBasicClient returns a test client from storage credentials in the env
func getBasicClient(c *chk.C) Client {
	name := os.Getenv("ACCOUNT_NAME")
	if name == "" {
		c.Fatal("ACCOUNT_NAME not set, need an empty storage account to test")
	}
	key := os.Getenv("ACCOUNT_KEY")
	if key == "" {
		c.Fatal("ACCOUNT_KEY not set")
	}
	cli, err := NewBasicClient(name, key)
	c.Assert(err, chk.IsNil)
	return cli
}
开发者ID:freimer,项目名称:azure-sdk-for-go,代码行数:14,代码来源: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: 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

示例15: 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


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