本文整理汇总了Golang中github.com/jrperritt/rack/internal/github.com/rackspace/gophercloud/testhelper.CheckDeepEquals函数的典型用法代码示例。如果您正苦于以下问题:Golang CheckDeepEquals函数的具体用法?Golang CheckDeepEquals怎么用?Golang CheckDeepEquals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CheckDeepEquals函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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)
}
}
示例2: 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)
}
示例3: 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)
}
示例4: 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)
}
示例5: 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)
}
示例6: 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])
}
示例7: 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)
}
示例8: TestBuildHeaders
func TestBuildHeaders(t *testing.T) {
testStruct := struct {
Accept string `h:"Accept"`
Num int `h:"Number,required"`
Style bool `h:"Style"`
}{
Accept: "application/json",
Num: 4,
Style: true,
}
expected := map[string]string{"Accept": "application/json", "Number": "4", "Style": "true"}
actual, err := BuildHeaders(&testStruct)
th.CheckNoErr(t, err)
th.CheckDeepEquals(t, expected, actual)
testStruct.Num = 0
_, err = BuildHeaders(&testStruct)
if err == nil {
t.Errorf("Expected error: 'Required header not set'")
}
_, err = BuildHeaders(map[string]interface{}{"Number": 4})
if err == nil {
t.Errorf("Expected error: 'Options type is not a struct'")
}
}
示例9: 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)
}
示例10: TestEnumerateMarker
func TestEnumerateMarker(t *testing.T) {
pager := createMarkerPaged(t)
defer testhelper.TeardownHTTP()
callCount := 0
err := pager.EachPage(func(page Page) (bool, error) {
actual, err := ExtractMarkerStrings(page)
if err != nil {
return false, err
}
t.Logf("Handler invoked with %v", actual)
var expected []string
switch callCount {
case 0:
expected = []string{"aaa", "bbb", "ccc"}
case 1:
expected = []string{"ddd", "eee", "fff"}
case 2:
expected = []string{"ggg", "hhh", "iii"}
default:
t.Fatalf("Unexpected call count: %d", callCount)
return false, nil
}
testhelper.CheckDeepEquals(t, expected, actual)
callCount++
return true, nil
})
testhelper.AssertNoErr(t, err)
testhelper.AssertEquals(t, callCount, 3)
}
示例11: 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.CheckDeepEquals(t, expectedErr, actualErr)
}
示例12: TestAuthenticatedHeaders
func TestAuthenticatedHeaders(t *testing.T) {
p := &ProviderClient{
TokenID: "1234",
}
expected := map[string]string{"X-Auth-Token": "1234"}
actual := p.AuthenticatedHeaders()
th.CheckDeepEquals(t, expected, actual)
}
示例13: TestBuildQueryString
func TestBuildQueryString(t *testing.T) {
type testVar string
opts := struct {
J int `q:"j"`
R string `q:"r,required"`
C bool `q:"c"`
S []string `q:"s"`
TS []testVar `q:"ts"`
TI []int `q:"ti"`
}{
J: 2,
R: "red",
C: true,
S: []string{"one", "two", "three"},
TS: []testVar{"a", "b"},
TI: []int{1, 2},
}
expected := &url.URL{RawQuery: "c=true&j=2&r=red&s=one&s=two&s=three&ti=1&ti=2&ts=a&ts=b"}
actual, err := BuildQueryString(&opts)
if err != nil {
t.Errorf("Error building query string: %v", err)
}
th.CheckDeepEquals(t, expected, actual)
opts = struct {
J int `q:"j"`
R string `q:"r,required"`
C bool `q:"c"`
S []string `q:"s"`
TS []testVar `q:"ts"`
TI []int `q:"ti"`
}{
J: 2,
C: true,
}
_, err = BuildQueryString(&opts)
if err == nil {
t.Errorf("Expected error: 'Required field not set'")
}
th.CheckDeepEquals(t, expected, actual)
_, err = BuildQueryString(map[string]interface{}{"Number": 4})
if err == nil {
t.Errorf("Expected error: 'Options type is not a struct'")
}
}
示例14: TestGet
func TestGet(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
os.HandleGetSuccessfully(t)
actual, err := Get(client.ServiceClient(), "firstkey").Extract()
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, &os.FirstKeyPair, actual)
}
示例15: TestGetObject
func TestGetObject(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
os.HandleGetObjectSuccessfully(t)
expected := map[string]string{"Gophercloud-Test": "objects"}
actual, err := Get(fake.ServiceClient(), "testContainer", "testObject", nil).ExtractMetadata()
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, expected, actual)
}