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


Golang testhelper.CheckEquals函數代碼示例

本文整理匯總了Golang中github.com/rackspace/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)
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:12,代碼來源:requests_test.go

示例2: TestCreateURL

func TestCreateURL(t *testing.T) {
    th.SetupHTTP()
    defer th.TeardownHTTP()
    c := client.ServiceClient()

    th.CheckEquals(t, c.Endpoint+"os-volumes_boot", createURL(c))
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:7,代碼來源:urls_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: 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:satyamkotakonda,項目名稱:rack,代碼行數:7,代碼來源:urls_test.go

示例5: TestListURL

func TestListURL(t *testing.T) {
    th.SetupHTTP()
    defer th.TeardownHTTP()
    c := client.ServiceClient()

    th.CheckEquals(t, c.Endpoint+"os-keypairs", listURL(c))
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:7,代碼來源:urls_test.go

示例6: TestV2EndpointNone

func TestV2EndpointNone(t *testing.T) {
    _, err := V2EndpointURL(&catalog2, gophercloud.EndpointOpts{
        Type:         "nope",
        Availability: gophercloud.AvailabilityPublic,
    })
    th.CheckEquals(t, ErrEndpointNotFound{}.Error(), err.Error())
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:7,代碼來源:endpoint_location_test.go

示例7: 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:satyamkotakonda,項目名稱:rack,代碼行數:27,代碼來源:client_test.go

示例8: 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)
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:18,代碼來源:provider_client_test.go

示例9: 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:satyamkotakonda,項目名稱:rack,代碼行數:18,代碼來源:results_test.go

示例10: TestV3EndpointBadAvailability

func TestV3EndpointBadAvailability(t *testing.T) {
    _, err := V3EndpointURL(&catalog3, gophercloud.EndpointOpts{
        Type:         "same",
        Name:         "same",
        Region:       "same",
        Availability: "wat",
    })
    th.CheckEquals(t, "Unexpected availability in endpoint query", err.Error())
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:9,代碼來源:endpoint_location_test.go

示例11: 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)
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:9,代碼來源:results_test.go

示例12: 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:satyamkotakonda,項目名稱:rack,代碼行數:9,代碼來源:delegate_test.go

示例13: TestUpdate

func TestUpdate(t *testing.T) {
    th.SetupHTTP()
    defer th.TeardownHTTP()

    MockUpdateResponse(t)

    options := UpdateOpts{Name: "vol-002"}
    v, err := Update(client.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22", options).Extract()
    th.AssertNoErr(t, err)
    th.CheckEquals(t, "vol-002", v.Name)
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:11,代碼來源:requests_test.go

示例14: TestExtractUpdate

func TestExtractUpdate(t *testing.T) {
    th.SetupHTTP()
    defer th.TeardownHTTP()
    servers.HandleServerUpdateSuccessfully(t)

    r := servers.Update(client.ServiceClient(), "1234asdf", servers.UpdateOpts{
        Name: "new-name",
    })
    config, err := ExtractUpdate(r)
    th.AssertNoErr(t, err)
    th.CheckEquals(t, Manual, *config)
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:12,代碼來源:results_test.go

示例15: TestDownloadExtraction

func TestDownloadExtraction(t *testing.T) {
    th.SetupHTTP()
    defer th.TeardownHTTP()
    HandleDownloadObjectSuccessfully(t)

    response := Download(fake.ServiceClient(), "testContainer", "testObject", nil)

    // Check []byte extraction
    bytes, err := response.ExtractContent()
    th.AssertNoErr(t, err)
    th.CheckEquals(t, "Successful download with Gophercloud", string(bytes))
}
開發者ID:nelsnelson,項目名稱:rack,代碼行數:12,代碼來源:requests_test.go


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