本文整理汇总了Golang中github.com/gophercloud/gophercloud/testhelper/fixture.SetupHandler函数的典型用法代码示例。如果您正苦于以下问题:Golang SetupHandler函数的具体用法?Golang SetupHandler怎么用?Golang SetupHandler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetupHandler函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestListGlobalParams
func TestListGlobalParams(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
fixture.SetupHandler(t, globalParamListURL, "GET", "", ListParamsJSON, 200)
pages := 0
err := configurations.ListGlobalParams(fake.ServiceClient(), versionID).EachPage(func(page pagination.Page) (bool, error) {
pages++
actual, err := configurations.ExtractParams(page)
if err != nil {
return false, err
}
expected := []configurations.Param{
{Max: 1, Min: 0, Name: "innodb_file_per_table", RestartRequired: true, Type: "integer"},
{Max: 4294967296, Min: 0, Name: "key_buffer_size", RestartRequired: false, Type: "integer"},
{Max: 65535, Min: 2, Name: "connect_timeout", RestartRequired: false, Type: "integer"},
{Max: 4294967296, Min: 0, Name: "join_buffer_size", RestartRequired: false, Type: "integer"},
}
th.AssertDeepEquals(t, actual, expected)
return true, nil
})
th.AssertNoErr(t, err)
th.AssertEquals(t, 1, pages)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:29,代码来源:requests_test.go
示例2: TestListInstances
func TestListInstances(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
fixture.SetupHandler(t, resURL+"/instances", "GET", "", ListInstancesJSON, 200)
expectedInstance := instances.Instance{
ID: "d4603f69-ec7e-4e9b-803f-600b9205576f",
Name: "json_rack_instance",
}
pages := 0
err := configurations.ListInstances(fake.ServiceClient(), configID).EachPage(func(page pagination.Page) (bool, error) {
pages++
actual, err := instances.ExtractInstances(page)
if err != nil {
return false, err
}
th.AssertDeepEquals(t, actual, []instances.Instance{expectedInstance})
return true, nil
})
th.AssertNoErr(t, err)
th.AssertEquals(t, 1, pages)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:27,代码来源:requests_test.go
示例3: TestDelete
func TestDelete(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
fixture.SetupHandler(t, resURL, "DELETE", "", "", 202)
err := configurations.Delete(fake.ServiceClient(), configID).ExtractErr()
th.AssertNoErr(t, err)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:8,代码来源:requests_test.go
示例4: TestGet
func TestGet(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
fixture.SetupHandler(t, resURL, "GET", "", GetConfigJSON, 200)
config, err := configurations.Get(fake.ServiceClient(), configID).Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, &ExampleConfig, config)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:9,代码来源:requests_test.go
示例5: TestGetVersion
func TestGetVersion(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
fixture.SetupHandler(t, "/datastores/{dsID}/versions/{versionID}", "GET", "", GetVersionResp, 200)
ds, err := datastores.GetVersion(fake.ServiceClient(), "{dsID}", "{versionID}").Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, &ExampleVersion1, ds)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:9,代码来源:requests_test.go
示例6: TestReplace
func TestReplace(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
fixture.SetupHandler(t, resURL, "PUT", UpdateReq, "", 202)
opts := configurations.UpdateOpts{
Values: map[string]interface{}{
"connect_timeout": 300,
},
}
err := configurations.Replace(fake.ServiceClient(), configID, opts).ExtractErr()
th.AssertNoErr(t, err)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:14,代码来源:requests_test.go
示例7: TestGetGlobalParam
func TestGetGlobalParam(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
fixture.SetupHandler(t, globalParamGetURL, "GET", "", GetParamJSON, 200)
param, err := configurations.GetGlobalParam(fake.ServiceClient(), versionID, paramID).Extract()
th.AssertNoErr(t, err)
expected := &configurations.Param{
Max: 1, Min: 0, Name: "innodb_file_per_table", RestartRequired: true, Type: "integer",
}
th.AssertDeepEquals(t, expected, param)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:14,代码来源:requests_test.go
示例8: TestList
func TestList(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
fixture.SetupHandler(t, _baseURL, "GET", "", ListConfigsJSON, 200)
count := 0
err := configurations.List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := configurations.ExtractConfigs(page)
th.AssertNoErr(t, err)
expected := []configurations.Config{ExampleConfig}
th.AssertDeepEquals(t, expected, actual)
return true, nil
})
th.AssertEquals(t, 1, count)
th.AssertNoErr(t, err)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:20,代码来源:requests_test.go
示例9: TestCreate
func TestCreate(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
fixture.SetupHandler(t, _baseURL, "POST", CreateReq, CreateConfigJSON, 200)
opts := configurations.CreateOpts{
Datastore: &configurations.DatastoreOpts{
Type: "a00000a0-00a0-0a00-00a0-000a000000aa",
Version: "b00000b0-00b0-0b00-00b0-000b000000bb",
},
Description: "example description",
Name: "example-configuration-name",
Values: map[string]interface{}{
"collation_server": "latin1_swedish_ci",
"connect_timeout": 120,
},
}
config, err := configurations.Create(fake.ServiceClient(), opts).Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, &ExampleConfigWithValues, config)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:22,代码来源:requests_test.go
示例10: TestListVersions
func TestListVersions(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
fixture.SetupHandler(t, "/datastores/{dsID}/versions", "GET", "", ListVersionsResp, 200)
pages := 0
err := datastores.ListVersions(fake.ServiceClient(), "{dsID}").EachPage(func(page pagination.Page) (bool, error) {
pages++
actual, err := datastores.ExtractVersions(page)
if err != nil {
return false, err
}
th.CheckDeepEquals(t, ExampleVersions, actual)
return true, nil
})
th.AssertNoErr(t, err)
th.AssertEquals(t, 1, pages)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:23,代码来源:requests_test.go
示例11: HandleIsRootEnabled
func HandleIsRootEnabled(t *testing.T) {
fixture.SetupHandler(t, uRootURL, "GET", "", isUserEnabledResp, 200)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:3,代码来源:fixtures.go
示例12: HandleDelete
func HandleDelete(t *testing.T) {
fixture.SetupHandler(t, _rootURL+"/{userName}", "DELETE", "", "", 202)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:3,代码来源:fixtures.go
示例13: HandleList
func HandleList(t *testing.T) {
fixture.SetupHandler(t, resURL, "GET", "", listDBsResp, 200)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:3,代码来源:fixtures.go
示例14: HandleGet
func HandleGet(t *testing.T) {
fixture.SetupHandler(t, resURL, "GET", "", getFlavorResp, 200)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:3,代码来源:fixtures.go
示例15: HandleList
func HandleList(t *testing.T) {
fixture.SetupHandler(t, _baseURL, "GET", "", listFlavorsResp, 200)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:3,代码来源:fixtures.go
示例16: HandleResizeVol
func HandleResizeVol(t *testing.T) {
fixture.SetupHandler(t, aURL, "POST", resizeVolReq, "", 202)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:3,代码来源:fixtures.go
示例17: HandleRestart
func HandleRestart(t *testing.T) {
fixture.SetupHandler(t, aURL, "POST", restartReq, "", 202)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:3,代码来源:fixtures.go
示例18: HandleCreate
func HandleCreate(t *testing.T) {
fixture.SetupHandler(t, _rootURL, "POST", createReq, "", 202)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:3,代码来源:fixtures.go
示例19: HandleList
func HandleList(t *testing.T) {
fixture.SetupHandler(t, rootURL, "GET", "", listInstancesResp, 200)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:3,代码来源:fixtures.go
示例20: HandleList
func HandleList(t *testing.T) {
fixture.SetupHandler(t, _rootURL, "GET", "", listResp, 200)
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:3,代码来源:fixtures.go
注:本文中的github.com/gophercloud/gophercloud/testhelper/fixture.SetupHandler函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论