本文整理汇总了Golang中github.com/jrperritt/rack/internal/github.com/rackspace/gophercloud/testhelper.CheckEquals函数的典型用法代码示例。如果您正苦于以下问题:Golang CheckEquals函数的具体用法?Golang CheckEquals怎么用?Golang CheckEquals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CheckEquals函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestCreateContainer
func TestCreateContainer(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleCreateContainerSuccessfully(t)
options := CreateOpts{ContentType: "application/json", Metadata: map[string]string{"foo": "bar"}}
res := Create(fake.ServiceClient(), "testContainer", options)
c, err := res.Extract()
th.CheckNoErr(t, err)
th.CheckEquals(t, "bar", res.Header["X-Container-Meta-Foo"][0])
th.CheckEquals(t, "1234567", c.TransID)
}
示例2: TestAuthenticatedClientV2
func TestAuthenticatedClientV2(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
th.Mux.HandleFunc("/v2.0/tokens", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, `
{
"access": {
"token": {
"id": "01234567890",
"expires": "2014-10-01T10:00:00.000000Z"
},
"serviceCatalog": []
}
}
`)
})
options := gophercloud.AuthOptions{
Username: "me",
APIKey: "09876543210",
IdentityEndpoint: th.Endpoint() + "v2.0/",
}
client, err := AuthenticatedClient(options)
th.AssertNoErr(t, err)
th.CheckEquals(t, "01234567890", client.TokenID)
}
示例3: TestV3EndpointNone
func TestV3EndpointNone(t *testing.T) {
_, err := V3EndpointURL(&catalog3, gophercloud.EndpointOpts{
Type: "nope",
Availability: gophercloud.AvailabilityPublic,
})
th.CheckEquals(t, ErrEndpointNotFound{}.Error(), err.Error())
}
示例4: 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)
}
示例5: TestListURL
func TestListURL(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
c := client.ServiceClient()
th.CheckEquals(t, c.Endpoint+"os-keypairs", listURL(c))
}
示例6: TestDeleteURL
func TestDeleteURL(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
c := client.ServiceClient()
th.CheckEquals(t, c.Endpoint+"os-keypairs/wat", deleteURL(c, "wat"))
}
示例7: TestCreateURL
func TestCreateURL(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
c := client.ServiceClient()
th.CheckEquals(t, c.Endpoint+"os-volumes_boot", createURL(c))
}
示例8: TestV2EndpointNone
func TestV2EndpointNone(t *testing.T) {
_, err := V2EndpointURL(&catalog2, gophercloud.EndpointOpts{
Type: "nope",
Availability: gophercloud.AvailabilityPublic,
})
th.CheckEquals(t, gophercloud.ErrEndpointNotFound, err)
}
示例9: tokenPostErr
func tokenPostErr(t *testing.T, options gophercloud.AuthOptions, expectedErr error) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleTokenPost(t, "")
actualErr := Create(client.ServiceClient(), AuthOptions{options}).Err
th.CheckEquals(t, expectedErr, actualErr)
}
示例10: TestListURL
func TestListURL(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
c := client.ServiceClient()
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
th.CheckEquals(t, c.Endpoint+"servers/"+serverId+"/os-volume_attachments", listURL(c, serverId))
}
示例11: TestExtractList
func TestExtractList(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
servers.HandleServerListSuccessfully(t)
pages := 0
err := servers.List(client.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
pages++
config, err := ExtractDiskConfig(page, 0)
th.AssertNoErr(t, err)
th.CheckEquals(t, Manual, *config)
return true, nil
})
th.AssertNoErr(t, err)
th.CheckEquals(t, pages, 1)
}
示例12: TestDeleteURL
func TestDeleteURL(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
c := client.ServiceClient()
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
aId := "a26887c6-c47b-4654-abb5-dfadf7d3f804"
th.CheckEquals(t, c.Endpoint+"servers/"+serverId+"/os-volume_attachments/"+aId, deleteURL(c, serverId, aId))
}
示例13: TestUserAgent
func TestUserAgent(t *testing.T) {
p := &ProviderClient{}
p.UserAgent.Prepend("custom-user-agent/2.4.0")
expected := "custom-user-agent/2.4.0 gophercloud/1.0.0"
actual := p.UserAgent.Join()
th.CheckEquals(t, expected, actual)
p.UserAgent.Prepend("another-custom-user-agent/0.3.0", "a-third-ua/5.9.0")
expected = "another-custom-user-agent/0.3.0 a-third-ua/5.9.0 custom-user-agent/2.4.0 gophercloud/1.0.0"
actual = p.UserAgent.Join()
th.CheckEquals(t, expected, actual)
p.UserAgent = UserAgent{}
expected = "gophercloud/1.0.0"
actual = p.UserAgent.Join()
th.CheckEquals(t, expected, actual)
}
示例14: TestDownloadObject
func TestDownloadObject(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
os.HandleDownloadObjectSuccessfully(t)
content, err := Download(fake.ServiceClient(), "testContainer", "testObject", nil).ExtractContent()
th.AssertNoErr(t, err)
th.CheckEquals(t, string(content), "Successful download with Gophercloud")
}
示例15: TestExtractGet
func TestExtractGet(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
servers.HandleServerGetSuccessfully(t)
config, err := ExtractGet(servers.Get(client.ServiceClient(), "1234asdf"))
th.AssertNoErr(t, err)
th.CheckEquals(t, Manual, *config)
}