Refactor to use new handler setup
diff --git a/openstack/db/v1/users/fixtures.go b/openstack/db/v1/users/fixtures.go
index 6bada41..25b75f1 100644
--- a/openstack/db/v1/users/fixtures.go
+++ b/openstack/db/v1/users/fixtures.go
@@ -1,91 +1,21 @@
package users
-import (
- "fmt"
- "net/http"
- "testing"
+import "fmt"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
+const user1 = `
+{"databases": [{"name": "databaseA"}],"name": "dbuser3"%s}
+`
+
+const user2 = `
+{"databases": [{"name": "databaseB"},{"name": "databaseC"}],"name": "dbuser4"%s}
+`
+
+var (
+ pUser1 = fmt.Sprintf(user1, `,"password":"secretsecret"`)
+ pUser2 = fmt.Sprintf(user2, `,"password":"secretsecret"`)
)
-func HandleCreateUserSuccessfully(t *testing.T, instanceID string) {
- th.Mux.HandleFunc("/instances/"+instanceID+"/users", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestJSONRequest(t, r, `
-{
- "users": [
- {
- "databases": [
- {
- "name": "databaseA"
- }
- ],
- "name": "dbuser3",
- "password": "secretsecret"
- },
- {
- "databases": [
- {
- "name": "databaseB"
- },
- {
- "name": "databaseC"
- }
- ],
- "name": "dbuser4",
- "password": "secretsecret"
- }
- ]
-}
-`)
-
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func HandleListUsersSuccessfully(t *testing.T, instanceID string) {
- th.Mux.HandleFunc("/instances/"+instanceID+"/users", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "users": [
- {
- "databases": [
- {
- "name": "databaseA"
- }
- ],
- "name": "dbuser3"
- },
- {
- "databases": [
- {
- "name": "databaseB"
- },
- {
- "name": "databaseC"
- }
- ],
- "name": "dbuser4"
- }
- ]
-}
-`)
- })
-}
-
-func HandleDeleteUserSuccessfully(t *testing.T, instanceID, dbName string) {
- th.Mux.HandleFunc("/instances/"+instanceID+"/users/"+dbName, func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusAccepted)
- })
-}
+var (
+ createReq = fmt.Sprintf(`{"users":[%s, %s]}`, pUser1, pUser2)
+ listResp = fmt.Sprintf(`{"users":[%s, %s]}`, fmt.Sprintf(user1, ""), fmt.Sprintf(user2, ""))
+)