本文整理汇总了Golang中github.com/rackspace/gophercloud/testhelper.CheckDeepEquals函数的典型用法代码示例。如果您正苦于以下问题:Golang CheckDeepEquals函数的具体用法?Golang CheckDeepEquals怎么用?Golang CheckDeepEquals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CheckDeepEquals函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestListMembers
func TestListMembers(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleMemberListSuccessfully(t)
pages := 0
err := ListAssociateMembers(fake.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853", MemberListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
pages++
actual, err := ExtractMembers(page)
if err != nil {
return false, err
}
if len(actual) != 2 {
t.Fatalf("Expected 2 members, got %d", len(actual))
}
th.CheckDeepEquals(t, MemberWeb, actual[0])
th.CheckDeepEquals(t, MemberDb, actual[1])
return true, nil
})
th.AssertNoErr(t, err)
if pages != 1 {
t.Errorf("Expected 1 page, saw %d", pages)
}
}
示例2: TestList
func TestList(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandlePolicyListSuccessfully(t)
pages := 0
pager := List(client.ServiceClient(), "60b15dad-5ea1-43fa-9a12-a1d737b4da07")
err := pager.EachPage(func(page pagination.Page) (bool, error) {
pages++
policies, err := ExtractPolicies(page)
if err != nil {
return false, err
}
if len(policies) != 3 {
t.Fatalf("Expected 3 policies, got %d", len(policies))
}
th.CheckDeepEquals(t, WebhookPolicy, policies[0])
th.CheckDeepEquals(t, OneTimePolicy, policies[1])
th.CheckDeepEquals(t, SundayAfternoonPolicy, policies[2])
return true, nil
})
th.AssertNoErr(t, err)
if pages != 1 {
t.Errorf("Expected 1 page, saw %d", pages)
}
}
示例3: TestListServers
func TestListServers(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleServerListSuccessfully(t)
pages := 0
err := List(client.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
pages++
actual, err := ExtractServers(page)
if err != nil {
return false, err
}
if len(actual) != 2 {
t.Fatalf("Expected 2 servers, got %d", len(actual))
}
th.CheckDeepEquals(t, ServerHerp, actual[0])
th.CheckDeepEquals(t, ServerDerp, actual[1])
return true, nil
})
th.AssertNoErr(t, err)
if pages != 1 {
t.Errorf("Expected 1 page, saw %d", pages)
}
}
示例4: GetIsSuccessful
// GetIsSuccessful ensures that a GetResult was successful and contains the correct token and
// User Info.
func GetIsSuccessful(t *testing.T, result GetResult) {
token, err := result.ExtractToken()
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, ExpectedToken, token)
user, err := result.ExtractUser()
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, ExpectedUser, user)
}
示例5: 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)
}
示例6: TestMaybeString
func TestMaybeString(t *testing.T) {
testString := ""
var expected *string
actual := MaybeString(testString)
th.CheckDeepEquals(t, expected, actual)
testString = "carol"
expected = &testString
actual = MaybeString(testString)
th.CheckDeepEquals(t, expected, actual)
}
示例7: TestMaybeInt
func TestMaybeInt(t *testing.T) {
testInt := 0
var expected *int
actual := MaybeInt(testInt)
th.CheckDeepEquals(t, expected, actual)
testInt = 4
expected = &testInt
actual = MaybeInt(testInt)
th.CheckDeepEquals(t, expected, actual)
}
示例8: TestApplyDefaultsToEndpointOpts
func TestApplyDefaultsToEndpointOpts(t *testing.T) {
eo := EndpointOpts{Availability: AvailabilityPublic}
eo.ApplyDefaults("compute")
expected := EndpointOpts{Availability: AvailabilityPublic, Type: "compute"}
th.CheckDeepEquals(t, expected, eo)
eo = EndpointOpts{Type: "compute"}
eo.ApplyDefaults("object-store")
expected = EndpointOpts{Availability: AvailabilityPublic, Type: "compute"}
th.CheckDeepEquals(t, expected, eo)
}
示例9: 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])
}
示例10: TestListAllMembers
func TestListAllMembers(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleMemberListSuccessfully(t)
allPages, err := ListAssociateMembers(fake.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853", MemberListOpts{}).AllPages()
th.AssertNoErr(t, err)
actual, err := ExtractMembers(allPages)
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, MemberWeb, actual[0])
th.CheckDeepEquals(t, MemberDb, actual[1])
}
示例11: TestListAllHealthmonitors
func TestListAllHealthmonitors(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleHealthmonitorListSuccessfully(t)
allPages, err := List(fake.ServiceClient(), ListOpts{}).AllPages()
th.AssertNoErr(t, err)
actual, err := ExtractMonitors(allPages)
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, HealthmonitorWeb, actual[0])
th.CheckDeepEquals(t, HealthmonitorDb, actual[1])
}
示例12: TestMeterStatistics
func TestMeterStatistics(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleMeterStatisticsSuccessfully(t)
list, err := MeterStatistics(client.ServiceClient(), "memory", MeterStatisticsOpts{}).Extract()
th.AssertNoErr(t, err)
if len(list) != 2 {
t.Fatalf("Expected 2 statistics, got %d", len(list))
}
th.CheckDeepEquals(t, StatisticsHerp, (list)[0])
th.CheckDeepEquals(t, StatisticsDerp, (list)[1])
}
示例13: TestListMeters
func TestListMeters(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleMeterListSuccessfully(t)
list, err := List(client.ServiceClient(), ListOpts{}).Extract()
th.AssertNoErr(t, err)
if len(list) != 2 {
t.Fatalf("Expected 2 meters, got %d", len(list))
}
th.CheckDeepEquals(t, MeterHerp, (list)[0])
th.CheckDeepEquals(t, MeterDerp, (list)[1])
}
示例14: TestRole
func TestRole(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
MockListRoleResponse(t)
count := 0
err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := os.ExtractRoles(page)
if err != nil {
t.Errorf("Failed to extract users: %v", err)
return false, err
}
expected := []os.Role{
os.Role{
ID: "123",
Name: "compute:admin",
Description: "Nova Administrator",
ServiceID: "cke5372ebabeeabb70a0e702a4626977x4406e5",
},
}
th.CheckDeepEquals(t, expected, actual)
return true, nil
})
th.AssertNoErr(t, err)
th.AssertEquals(t, 1, count)
}
示例15: TestListByServer
func TestListByServer(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
mockListGroupsByServerResponse(t, serverID)
count := 0
err := ListByServer(client.ServiceClient(), serverID).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractSecurityGroups(page)
if err != nil {
t.Errorf("Failed to extract users: %v", err)
return false, err
}
expected := []SecurityGroup{
SecurityGroup{
ID: groupID,
Description: "default",
Name: "default",
Rules: []Rule{},
TenantID: "openstack",
},
}
th.CheckDeepEquals(t, expected, actual)
return true, nil
})
th.AssertNoErr(t, err)
th.AssertEquals(t, 1, count)
}