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

Golang testhelper.AssertNoErr函数代码示例

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

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



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

示例1: TestListAll

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

	MockListResponse(t)

	allPages, err := List(client.ServiceClient(), &ListOpts{}).AllPages()
	th.AssertNoErr(t, err)
	actual, err := ExtractVolumes(allPages)
	th.AssertNoErr(t, err)

	expected := []Volume{
		Volume{
			ID:   "289da7f8-6440-407c-9fb4-7db01ec49164",
			Name: "vol-001",
		},
		Volume{
			ID:   "96c3bda7-c82a-4f50-be73-ca7621794835",
			Name: "vol-002",
		},
	}

	th.CheckDeepEquals(t, expected, actual)

}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:25,代码来源:requests_test.go


示例2: uploadLargeObject

func uploadLargeObject(t *testing.T, containerName, objectName string, sizeFile int64, sizePieces int) {
	letters := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

	sizeFile = int64(sizeFile * 1000000)

	tempFile, err := ioutil.TempFile("", "tmp")
	th.AssertNoErr(t, err)

	defer func() {
		err := os.Remove(tempFile.Name())
		th.AssertNoErr(t, err)
	}()

	data := make([]byte, sizeFile)
	for i := range data {
		data[i] = byte(letters[rand.Intn(len(letters))])
	}

	err = ioutil.WriteFile(tempFile.Name(), data, 0777)
	th.AssertNoErr(t, err)

	_, err = exec.Command("rack", "files", "large-object", "upload", "--output", "json",
		"--container", containerName, "--name", objectName, "--file", tempFile.Name(), "--size-pieces", strconv.Itoa(sizePieces)).Output()
	th.AssertNoErr(t, err)

}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:26,代码来源:largeobject_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: updateStack

func updateStack(t *testing.T, stackID string) {
	output, err := exec.Command("rack", "orchestration", "stack", "update", "--output", "json", "--id", stackID,
		"--template-url", updateTemplateURL).Output()
	th.AssertNoErr(t, err)
	var stack stackUpdatedResponse
	err = json.Unmarshal(output, &stack)
	th.AssertNoErr(t, err)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:8,代码来源:stackcommands_test.go


示例5: previewStack

func previewStack(t *testing.T) {
	output, err := exec.Command("rack", "orchestration", "stack", "preview", "--output", "json", "--template-url",
		createTemplateURL, "--name", "rackAcceptanceTestStackCreated").Output()
	th.AssertNoErr(t, err)
	var stack stackPreviewedResponse
	err = json.Unmarshal(output, &stack)
	th.AssertNoErr(t, err)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:8,代码来源:stackcommands_test.go


示例6: IsSuccessful

// IsSuccessful ensures that a CreateResult was successful and contains the correct token and
// service catalog.
func IsSuccessful(t *testing.T, result CreateResult) {
	token, err := result.ExtractToken()
	th.AssertNoErr(t, err)
	th.CheckDeepEquals(t, ExpectedToken, token)

	serviceCatalog, err := result.ExtractServiceCatalog()
	th.AssertNoErr(t, err)
	th.CheckDeepEquals(t, ExpectedServiceCatalog, serviceCatalog)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:11,代码来源:fixtures.go


示例7: updateServer

func updateServer(t *testing.T, serverID string) {
	output, err := exec.Command("rack", "servers", "instance", "update", "--output", "json", "--id", serverID,
		"--rename", "rackAcceptanceTestUpdated").Output()
	th.AssertNoErr(t, err)
	var server osServers.Server
	err = json.Unmarshal(output, &server)
	th.AssertNoErr(t, err)
	th.AssertEquals(t, "rackAcceptanceTestUpdated", server.Name)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:9,代码来源:instance_test.go


示例8: rebootServer

func rebootServer(t *testing.T, serverID string) {
	output, err := exec.Command("rack", "servers", "instance", "reboot", "--output", "json", "--id", serverID, "--soft", "--wait-for-completion").Output()
	th.AssertNoErr(t, err)
	type result struct {
		result string
	}
	var res result
	err = json.Unmarshal(output, &res)
	th.AssertNoErr(t, err)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:10,代码来源:instance_test.go


示例9: createServer

func createServer(t *testing.T) *osServers.Server {
	output, err := exec.Command("rack", "servers", "instance", "create", "--output", "json", "--image-id",
		"09de0a66-3156-48b4-90a5-1cf25a905207", "--flavor-id", "3", "--name", "rackAcceptanceTestCreated", "--wait-for-completion").Output()
	th.AssertNoErr(t, err)

	var server osServers.Server
	err = json.Unmarshal(output, &server)
	th.AssertNoErr(t, err)

	return &server
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:11,代码来源:instance_test.go


示例10: TestListAllContainerNames

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

	allPages, err := List(fake.ServiceClient(), &ListOpts{Full: false}).AllPages()
	th.AssertNoErr(t, err)
	actual, err := ExtractNames(allPages)
	th.AssertNoErr(t, err)
	th.CheckDeepEquals(t, ExpectedListNames, actual)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:11,代码来源:requests_test.go


示例11: TestAllPagesLinked

func TestAllPagesLinked(t *testing.T) {
	pager := createLinked(t)
	defer testhelper.TeardownHTTP()

	page, err := pager.AllPages()
	testhelper.AssertNoErr(t, err)

	expected := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	actual, err := ExtractLinkedInts(page)
	testhelper.AssertNoErr(t, err)
	testhelper.CheckDeepEquals(t, expected, actual)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:12,代码来源:linked_test.go


示例12: TestListAllServers

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

	allPages, err := List(client.ServiceClient(), ListOpts{}).AllPages()
	th.AssertNoErr(t, err)
	actual, err := ExtractServers(allPages)
	th.AssertNoErr(t, err)
	th.CheckDeepEquals(t, ServerHerp, actual[0])
	th.CheckDeepEquals(t, ServerDerp, actual[1])
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:12,代码来源:requests_test.go


示例13: deleteServer

func deleteServer(t *testing.T, serverID string) {
	fmt.Println("Deleting server...")
	output, err := exec.Command("rack", "servers", "instance", "delete", "--output", "json", "--id", serverID, "--wait-for-completion").Output()
	th.AssertNoErr(t, err)

	type result struct {
		result string
	}
	var res result
	err = json.Unmarshal(output, &res)
	th.AssertNoErr(t, err)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:12,代码来源:instance_test.go


示例14: TestAllPagesSingle

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

	page, err := pager.AllPages()
	testhelper.AssertNoErr(t, err)

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


示例15: TestAllPagesMarker

func TestAllPagesMarker(t *testing.T) {
	pager := createMarkerPaged(t)
	defer testhelper.TeardownHTTP()

	page, err := pager.AllPages()
	testhelper.AssertNoErr(t, err)

	expected := []string{"aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii"}
	actual, err := ExtractMarkerStrings(page)
	testhelper.AssertNoErr(t, err)
	testhelper.CheckDeepEquals(t, expected, actual)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:12,代码来源:marker_test.go


示例16: adoptStack

func adoptStack(t *testing.T, adoptData []byte) *stackCreatedResponse {
	// write adoptData to a temporary file
	adoptFile, err := ioutil.TempFile(os.TempDir(), "adoptFile")
	th.AssertNoErr(t, err)
	defer os.Remove(adoptFile.Name())
	adoptFile.Write(adoptData)

	output, err := exec.Command("rack", "orchestration", "stack", "adopt", "--adopt-file", adoptFile.Name(), "--name", "rackAcceptanceTestStackCreated", "--output", "json").Output()
	th.AssertNoErr(t, err)
	var stack stackCreatedResponse
	err = json.Unmarshal(output, &stack)
	th.AssertNoErr(t, err)
	return &stack
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:14,代码来源:stackcommands_test.go


示例17: TestUploadHandlePipe

func TestUploadHandlePipe(t *testing.T) {
	cmd := &commandUpload{}

	actual := &handler.Resource{
		Params: &paramsUpload{},
	}

	f, err := ioutil.TempFile("", "bar")
	th.AssertNoErr(t, err)
	defer os.Remove(f.Name())

	err = cmd.HandlePipe(actual, f.Name())
	th.AssertNoErr(t, err)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:14,代码来源:upload_test.go


示例18: TestCreatePreTable

func TestCreatePreTable(t *testing.T) {
	cmd := &commandAbandon{
		Ctx: &handler.Context{
			ServiceClient: client.ServiceClient(),
		},
	}

	resource := &handler.Resource{
		Params: &paramsCreate{},
	}

	expected := "{\"ID\":\"16ef0584-4458-41eb-87c8-0dc8d5f66c87\",\"Links\":[{\"Href\":\"http://168.28.170.117:8004/v1/98606384f58drad0bhdb7d02779549ac/stacks/stackcreated/16ef0584-4458-41eb-87c8-0dc8d5f66c87\",\"Rel\":\"self\"}]}"
	resource.Result = &osStacks.CreatedStack{
		ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
		Links: []gophercloud.Link{
			gophercloud.Link{
				Href: "http://168.28.170.117:8004/v1/98606384f58drad0bhdb7d02779549ac/stacks/stackcreated/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
				Rel:  "self",
			},
		},
	}
	err := cmd.PreTable(resource)
	th.AssertNoErr(t, err)
	actual, _ := json.Marshal(resource.Result)
	th.AssertEquals(t, expected, string(actual))
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:26,代码来源:create_test.go


示例19: TestCreateExecute

func TestCreateExecute(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	th.Mux.HandleFunc("/stacks", func(w http.ResponseWriter, r *http.Request) {
		th.TestMethod(t, r, "POST")
		w.Header().Add("Content-Type", "application/json")
		w.WriteHeader(http.StatusAccepted)
		fmt.Fprintf(w, `{"stack": {"id": "3095aefc-09fb-4bc7-b1f0-f21a304e864c"}}`)
	})
	cmd := &commandCreate{
		Ctx: &handler.Context{
			ServiceClient: client.ServiceClient(),
		},
	}
	templateOpts := new(osStacks.Template)
	templateOpts.Bin = []byte(`"heat_template_version": "2014-10-16"`)
	actual := &handler.Resource{
		Params: &paramsCreate{
			opts: &osStacks.CreateOpts{
				Name:         "stack1",
				TemplateOpts: templateOpts,
				Parameters: map[string]string{
					"img":    "foo",
					"flavor": "bar",
				},
			},
		},
	}
	cmd.Execute(actual)
	th.AssertNoErr(t, actual.Err)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:31,代码来源:create_test.go


示例20: TestListHandleSingle

func TestListHandleSingle(t *testing.T) {
	app := cli.NewApp()
	flagset := flag.NewFlagSet("flags", 1)
	flagset.String("stack-name", "", "")
	flagset.String("stack-id", "", "")
	flagset.Set("stack-name", "stack1")
	flagset.Set("stack-id", "id1")
	c := cli.NewContext(app, flagset, nil)
	cmd := &commandList{
		Ctx: &handler.Context{
			CLIContext: c,
		},
	}

	expected := &handler.Resource{
		Params: &paramsList{
			stackName: "stack1",
			stackID:   "id1",
		},
	}
	actual := &handler.Resource{
		Params: &paramsList{},
	}
	err := cmd.HandleSingle(actual)
	th.AssertNoErr(t, err)
	th.AssertEquals(t, expected.Params.(*paramsList).stackName, actual.Params.(*paramsList).stackName)
	th.AssertEquals(t, expected.Params.(*paramsList).stackID, actual.Params.(*paramsList).stackID)
}
开发者ID:satyamkotakonda,项目名称:rack,代码行数:28,代码来源:list_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang testhelper.CheckDeepEquals函数代码示例发布时间:2022-05-28
下一篇:
Golang testhelper.AssertEquals函数代码示例发布时间: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