本文整理汇总了Golang中github.com/rackspace/gophercloud/testhelper.CheckEquals函数的典型用法代码示例。如果您正苦于以下问题:Golang CheckEquals函数的具体用法?Golang CheckEquals怎么用?Golang CheckEquals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CheckEquals函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestAccounts
func TestAccounts(t *testing.T) {
c, err := createClient(t, false)
th.AssertNoErr(t, err)
updateHeaders, err := raxAccounts.Update(c, raxAccounts.UpdateOpts{Metadata: map[string]string{"white": "mountains"}}).Extract()
th.AssertNoErr(t, err)
t.Logf("Update Account Response Headers: %+v\n", updateHeaders)
defer func() {
updateres := raxAccounts.Update(c, raxAccounts.UpdateOpts{Metadata: map[string]string{"white": ""}})
th.AssertNoErr(t, updateres.Err)
metadata, err := raxAccounts.Get(c).ExtractMetadata()
th.AssertNoErr(t, err)
t.Logf("Metadata from Get Account request (after update reverted): %+v\n", metadata)
th.CheckEquals(t, metadata["White"], "")
}()
getResp := raxAccounts.Get(c)
th.AssertNoErr(t, getResp.Err)
getHeaders, _ := getResp.Extract()
t.Logf("Get Account Response Headers: %+v\n", getHeaders)
metadata, _ := getResp.ExtractMetadata()
t.Logf("Metadata from Get Account request (after update): %+v\n", metadata)
th.CheckEquals(t, metadata["White"], "mountains")
}
开发者ID:RomainVabre,项目名称:origin,代码行数:27,代码来源:accounts_test.go
示例2: TestGetExtension
func TestGetExtension(t *testing.T) {
service := authenticatedClient(t)
ext, err := extensions2.Get(service, "OS-KSCRUD").Extract()
th.AssertNoErr(t, err)
th.CheckEquals(t, "OpenStack Keystone User CRUD", ext.Name)
th.CheckEquals(t, "http://docs.openstack.org/identity/api/ext/OS-KSCRUD/v1.0", ext.Namespace)
th.CheckEquals(t, "OS-KSCRUD", ext.Alias)
th.CheckEquals(t, "OpenStack extensions to Keystone v2.0 API enabling User Operations.", ext.Description)
}
开发者ID:RomainVabre,项目名称:origin,代码行数:11,代码来源:extension_test.go
示例3: 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)
}
开发者ID:RomainVabre,项目名称:origin,代码行数:12,代码来源:requests_test.go
示例4: TestListURL
func TestListURL(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
c := client.ServiceClient()
th.CheckEquals(t, c.Endpoint+"os-keypairs", listURL(c))
}
开发者ID:RomainVabre,项目名称:origin,代码行数:7,代码来源:urls_test.go
示例5: TestList
func TestList(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
th.Mux.HandleFunc("/os-networksv2", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, `
{
"networks": [
{
"label": "test-network-1",
"cidr": "192.168.100.0/24",
"id": "d32019d3-bc6e-4319-9c1d-6722fc136a22"
},
{
"label": "test-network-2",
"cidr": "192.30.250.00/18",
"id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324"
}
]
}
`)
})
client := fake.ServiceClient()
count := 0
err := List(client).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractNetworks(page)
if err != nil {
t.Errorf("Failed to extract networks: %v", err)
return false, err
}
expected := []Network{
Network{
Label: "test-network-1",
CIDR: "192.168.100.0/24",
ID: "d32019d3-bc6e-4319-9c1d-6722fc136a22",
},
Network{
Label: "test-network-2",
CIDR: "192.30.250.00/18",
ID: "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
},
}
th.CheckDeepEquals(t, expected, actual)
return true, nil
})
th.AssertNoErr(t, err)
th.CheckEquals(t, 1, count)
}
开发者ID:RomainVabre,项目名称:origin,代码行数:60,代码来源:requests_test.go
示例6: 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)
}
开发者ID:RomainVabre,项目名称:origin,代码行数:27,代码来源:client_test.go
示例7: TestGetVolumes
func (s *CinderV2Suite) TestGetVolumes() {
Convey("Given Cinder volumes are requested", s.T(), func() {
Convey("When authentication is required", func() {
provider, err := openstackintel.Authenticate(th.Endpoint(), "me", "secret", "tenant")
th.AssertNoErr(s.T(), err)
th.CheckEquals(s.T(), s.Token, provider.TokenID)
Convey("and GetVolumes called", func() {
dispatch := ServiceV2{}
volumes, err := dispatch.GetVolumes(provider)
Convey("Then proper limits values are returned", func() {
So(len(volumes), ShouldEqual, 2)
So(volumes[s.Tenant1ID].Bytes, ShouldEqual, s.Vol1Size*1024*1024*1024)
So(volumes[s.Tenant2ID].Bytes, ShouldEqual, s.Vol2Size*1024*1024*1024)
So(volumes[s.Tenant1ID].Count, ShouldEqual, 1)
So(volumes[s.Tenant2ID].Count, ShouldEqual, 1)
})
Convey("and no error reported", func() {
So(err, ShouldBeNil)
})
})
})
})
}
开发者ID:intelsdi-x,项目名称:snap-plugin-collector-cinder,代码行数:27,代码来源:cinder_test.go
示例8: TestV3EndpointNoService
func TestV3EndpointNoService(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
th.Mux.HandleFunc("/services", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
fmt.Fprintf(w, `
{
"links": {
"next": null,
"previous": null
},
"services": []
}
`)
})
_, err := V3EndpointURL(fake.ServiceClient(), gophercloud.EndpointOpts{
Type: "nope",
Name: "same",
Region: "same",
Availability: gophercloud.AvailabilityPublic,
})
th.CheckEquals(t, gophercloud.ErrServiceNotFound, err)
}
开发者ID:hortonworks,项目名称:kubernetes-yarn,代码行数:28,代码来源:endpoint_location_test.go
示例9: TestV2EndpointNone
func TestV2EndpointNone(t *testing.T) {
_, err := V2EndpointURL(&catalog2, gophercloud.EndpointOpts{
Type: "nope",
Availability: gophercloud.AvailabilityPublic,
})
th.CheckEquals(t, gophercloud.ErrEndpointNotFound, err)
}
开发者ID:RomainVabre,项目名称:origin,代码行数:7,代码来源:endpoint_location_test.go
示例10: 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:RomainVabre,项目名称:origin,代码行数:33,代码来源:delegate_test.go
示例11: TestCreateURL
func TestCreateURL(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
c := client.ServiceClient()
th.CheckEquals(t, c.Endpoint+"os-floating-ips", createURL(c))
}
开发者ID:RomainVabre,项目名称:origin,代码行数:7,代码来源:urls_test.go
示例12: TestGetURL
func TestGetURL(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
c := client.ServiceClient()
th.CheckEquals(t, c.Endpoint+"os-quota-sets/wat", getURL(c, "wat"))
}
开发者ID:RomainVabre,项目名称:origin,代码行数:7,代码来源:urls_test.go
示例13: 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"))
}
开发者ID:RomainVabre,项目名称:origin,代码行数:7,代码来源:urls_test.go
示例14: TestKeystoneLogin
func TestKeystoneLogin(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
const ID = "0123456789"
th.Mux.HandleFunc("/v3/auth/tokens", func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("X-Subject-Token", ID)
type AuthRequest struct {
Auth struct {
Identity struct {
Password struct {
User struct {
Domain struct{ Name string }
Name string
Password string
}
}
}
}
}
var x AuthRequest
body, _ := ioutil.ReadAll(r.Body)
json.Unmarshal(body, &x)
domainName := x.Auth.Identity.Password.User.Domain.Name
userName := x.Auth.Identity.Password.User.Name
password := x.Auth.Identity.Password.User.Password
if domainName == "default" && userName == "testuser" && password == "testpw" {
w.WriteHeader(http.StatusCreated)
fmt.Fprintf(w, `{ "token": { "expires_at": "2020-02-02T18:30:59.000000Z" } }`)
} else {
w.WriteHeader(http.StatusUnauthorized)
}
})
keystoneAuth := New("keystone_auth", th.Endpoint(), http.DefaultTransport, "default", &TestUserIdentityMapper{})
_, ok, err := keystoneAuth.AuthenticatePassword("testuser", "testpw")
th.AssertNoErr(t, err)
th.CheckEquals(t, ok, true)
_, ok, err = keystoneAuth.AuthenticatePassword("testuser", "badpw")
th.AssertNoErr(t, err)
th.CheckEquals(t, ok, false)
_, ok, err = keystoneAuth.AuthenticatePassword("testuser", "")
th.AssertNoErr(t, err)
th.CheckEquals(t, ok, false)
}
开发者ID:RomainVabre,项目名称:origin,代码行数:46,代码来源:keystonepassword_test.go
示例15: TestGetURL
func TestGetURL(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
c := client.ServiceClient()
id := "1"
th.CheckEquals(t, c.Endpoint+"os-tenant-networks/"+id, getURL(c, id))
}
开发者ID:RomainVabre,项目名称:origin,代码行数:8,代码来源:urls_test.go
示例16: TestDisassociateURL
func TestDisassociateURL(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
c := client.ServiceClient()
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
th.CheckEquals(t, c.Endpoint+"servers/"+serverId+"/action", disassociateURL(c, serverId))
}
开发者ID:RomainVabre,项目名称:origin,代码行数:8,代码来源:urls_test.go
示例17: TestDeleteURL
func TestDeleteURL(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
c := client.ServiceClient()
id := "1"
th.CheckEquals(t, c.Endpoint+"os-floating-ips/"+id, deleteURL(c, id))
}
开发者ID:RomainVabre,项目名称:origin,代码行数:8,代码来源:urls_test.go
示例18: 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)
}
开发者ID:hortonworks,项目名称:kubernetes-yarn,代码行数:8,代码来源:requests_test.go
示例19: 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)
}
开发者ID:RomainVabre,项目名称:origin,代码行数:18,代码来源:results_test.go
示例20: 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")
}
开发者ID:chenzhen411,项目名称:kubernetes,代码行数:9,代码来源:delegate_test.go
注:本文中的github.com/rackspace/gophercloud/testhelper.CheckEquals函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论