test fixes
diff --git a/rackspace/db/v1/configurations/delegate_test.go b/rackspace/db/v1/configurations/delegate_test.go
index af5e8aa..580f02a 100644
--- a/rackspace/db/v1/configurations/delegate_test.go
+++ b/rackspace/db/v1/configurations/delegate_test.go
@@ -28,7 +28,7 @@
func TestList(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- fixture.SetupHandler(t, _baseURL, "GET", "", os.ListConfigsJSON, 200)
+ fixture.SetupHandler(t, _baseURL, "GET", "", listConfigsJSON, 200)
count := 0
err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
@@ -36,7 +36,7 @@
actual, err := os.ExtractConfigs(page)
th.AssertNoErr(t, err)
- expected := []os.Config{os.ExampleConfig}
+ expected := []os.Config{exampleConfig}
th.AssertDeepEquals(t, expected, actual)
return true, nil
@@ -49,17 +49,17 @@
func TestGet(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL, "GET", "", os.GetConfigJSON, 200)
+ fixture.SetupHandler(t, resURL, "GET", "", getConfigJSON, 200)
config, err := Get(fake.ServiceClient(), configID).Extract()
th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, &os.ExampleConfig, config)
+ th.AssertDeepEquals(t, &exampleConfig, config)
}
func TestCreate(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- fixture.SetupHandler(t, _baseURL, "POST", os.CreateReq, os.CreateConfigJSON, 200)
+ fixture.SetupHandler(t, _baseURL, "POST", createReq, createConfigJSON, 200)
opts := os.CreateOpts{
Datastore: &os.DatastoreOpts{
@@ -76,13 +76,13 @@
config, err := Create(fake.ServiceClient(), opts).Extract()
th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, &os.ExampleConfigWithValues, config)
+ th.AssertDeepEquals(t, &exampleConfigWithValues, config)
}
func TestUpdate(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL, "PATCH", os.UpdateReq, "", 200)
+ fixture.SetupHandler(t, resURL, "PATCH", updateReq, "", 200)
opts := os.UpdateOpts{
Values: map[string]interface{}{
@@ -97,7 +97,7 @@
func TestReplace(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL, "PUT", os.UpdateReq, "", 202)
+ fixture.SetupHandler(t, resURL, "PUT", updateReq, "", 202)
opts := os.UpdateOpts{
Values: map[string]interface{}{
@@ -121,7 +121,7 @@
func TestListInstances(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL+"/instances", "GET", "", os.ListInstancesJSON, 200)
+ fixture.SetupHandler(t, resURL+"/instances", "GET", "", listInstancesJSON, 200)
expectedInstance := instances.Instance{
ID: "d4603f69-ec7e-4e9b-803f-600b9205576f",
@@ -149,7 +149,7 @@
func TestListDSParams(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- fixture.SetupHandler(t, dsParamListURL, "GET", "", os.ListParamsJSON, 200)
+ fixture.SetupHandler(t, dsParamListURL, "GET", "", listParamsJSON, 200)
pages := 0
err := ListDatastoreParams(fake.ServiceClient(), dsID, versionID).EachPage(func(page pagination.Page) (bool, error) {
@@ -179,7 +179,7 @@
func TestGetDSParam(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- fixture.SetupHandler(t, dsParamGetURL, "GET", "", os.GetParamJSON, 200)
+ fixture.SetupHandler(t, dsParamGetURL, "GET", "", getParamJSON, 200)
param, err := GetDatastoreParam(fake.ServiceClient(), dsID, versionID, paramID).Extract()
th.AssertNoErr(t, err)
@@ -194,7 +194,7 @@
func TestListGlobalParams(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- fixture.SetupHandler(t, globalParamListURL, "GET", "", os.ListParamsJSON, 200)
+ fixture.SetupHandler(t, globalParamListURL, "GET", "", listParamsJSON, 200)
pages := 0
err := ListGlobalParams(fake.ServiceClient(), versionID).EachPage(func(page pagination.Page) (bool, error) {
@@ -224,7 +224,7 @@
func TestGetGlobalParam(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- fixture.SetupHandler(t, globalParamGetURL, "GET", "", os.GetParamJSON, 200)
+ fixture.SetupHandler(t, globalParamGetURL, "GET", "", getParamJSON, 200)
param, err := GetGlobalParam(fake.ServiceClient(), versionID, paramID).Extract()
th.AssertNoErr(t, err)
diff --git a/rackspace/db/v1/configurations/fixtures.go b/rackspace/db/v1/configurations/fixtures.go
new file mode 100644
index 0000000..aeacb0e
--- /dev/null
+++ b/rackspace/db/v1/configurations/fixtures.go
@@ -0,0 +1,153 @@
+package configurations
+
+import (
+ "fmt"
+
+ os "github.com/rackspace/gophercloud/openstack/db/v1/configurations"
+)
+
+const singleConfigJSON = `
+{
+ "created": "2014-07-31T18:56:09",
+ "datastore_name": "mysql",
+ "datastore_version_id": "b00000b0-00b0-0b00-00b0-000b000000bb",
+ "datastore_version_name": "5.6",
+ "description": "example_description",
+ "id": "005a8bb7-a8df-40ee-b0b7-fc144641abc2",
+ "name": "example-configuration-name",
+ "updated": "2014-07-31T18:56:09"
+}
+`
+
+const singleConfigWithValuesJSON = `
+{
+ "created": "2014-07-31T15:02:52",
+ "datastore_name": "mysql",
+ "datastore_version_id": "b00000b0-00b0-0b00-00b0-000b000000bb",
+ "datastore_version_name": "5.6",
+ "description": "example description",
+ "id": "005a8bb7-a8df-40ee-b0b7-fc144641abc2",
+ "instance_count": 0,
+ "name": "example-configuration-name",
+ "updated": "2014-07-31T15:02:52",
+ "values": {
+ "collation_server": "latin1_swedish_ci",
+ "connect_timeout": 120
+ }
+}
+`
+
+var (
+ listConfigsJSON = fmt.Sprintf(`{"configurations": [%s]}`, singleConfigJSON)
+ getConfigJSON = fmt.Sprintf(`{"configuration": %s}`, singleConfigJSON)
+ createConfigJSON = fmt.Sprintf(`{"configuration": %s}`, singleConfigWithValuesJSON)
+)
+
+var createReq = `
+{
+ "configuration": {
+ "datastore": {
+ "type": "a00000a0-00a0-0a00-00a0-000a000000aa",
+ "version": "b00000b0-00b0-0b00-00b0-000b000000bb"
+ },
+ "description": "example description",
+ "name": "example-configuration-name",
+ "values": {
+ "collation_server": "latin1_swedish_ci",
+ "connect_timeout": 120
+ }
+ }
+}
+`
+
+var updateReq = `
+{
+ "configuration": {
+ "values": {
+ "connect_timeout": 300
+ }
+ }
+}
+`
+
+var listInstancesJSON = `
+{
+ "instances": [
+ {
+ "id": "d4603f69-ec7e-4e9b-803f-600b9205576f",
+ "name": "json_rack_instance"
+ }
+ ]
+}
+`
+
+var listParamsJSON = `
+{
+ "configuration-parameters": [
+ {
+ "max": 1,
+ "min": 0,
+ "name": "innodb_file_per_table",
+ "restart_required": true,
+ "type": "integer"
+ },
+ {
+ "max": 4294967296,
+ "min": 0,
+ "name": "key_buffer_size",
+ "restart_required": false,
+ "type": "integer"
+ },
+ {
+ "max": 65535,
+ "min": 2,
+ "name": "connect_timeout",
+ "restart_required": false,
+ "type": "integer"
+ },
+ {
+ "max": 4294967296,
+ "min": 0,
+ "name": "join_buffer_size",
+ "restart_required": false,
+ "type": "integer"
+ }
+ ]
+}
+`
+
+var getParamJSON = `
+{
+ "max": 1,
+ "min": 0,
+ "name": "innodb_file_per_table",
+ "restart_required": true,
+ "type": "integer"
+}
+`
+
+var exampleConfig = os.Config{
+ Created: "2014-07-31T18:56:09",
+ DatastoreName: "mysql",
+ DatastoreVersionID: "b00000b0-00b0-0b00-00b0-000b000000bb",
+ DatastoreVersionName: "5.6",
+ Description: "example_description",
+ ID: "005a8bb7-a8df-40ee-b0b7-fc144641abc2",
+ Name: "example-configuration-name",
+ Updated: "2014-07-31T18:56:09",
+}
+
+var exampleConfigWithValues = os.Config{
+ Created: "2014-07-31T15:02:52",
+ DatastoreName: "mysql",
+ DatastoreVersionID: "b00000b0-00b0-0b00-00b0-000b000000bb",
+ DatastoreVersionName: "5.6",
+ Description: "example description",
+ ID: "005a8bb7-a8df-40ee-b0b7-fc144641abc2",
+ Name: "example-configuration-name",
+ Updated: "2014-07-31T15:02:52",
+ Values: map[string]interface{}{
+ "collation_server": "latin1_swedish_ci",
+ "connect_timeout": 120,
+ },
+}