當前位置: 首頁>>代碼示例>>Golang>>正文


Golang testhelper.AssertNoErr函數代碼示例

本文整理匯總了Golang中github.com/rackspace/rack/internal/github.com/rackspace/gophercloud/testhelper.AssertNoErr函數的典型用法代碼示例。如果您正苦於以下問題:Golang AssertNoErr函數的具體用法?Golang AssertNoErr怎麽用?Golang AssertNoErr使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了AssertNoErr函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的github.com/rackspace/rack/internal/github.com/rackspace/gophercloud/testhelper.AssertNoErr函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。