Server Metadata Update (#93)
This commit updates the Server Metadata so it can be parsed and
translated using JSON tags.
The Server Metadata result has been changed to map[string]string to
match the request.
A unit test was added to verify the above and a piece of metadata has
been added to the server creation acceptance test.
diff --git a/openstack/compute/v2/servers/testing/fixtures.go b/openstack/compute/v2/servers/testing/fixtures.go
index 1e56a00..bb25643 100644
--- a/openstack/compute/v2/servers/testing/fixtures.go
+++ b/openstack/compute/v2/servers/testing/fixtures.go
@@ -352,7 +352,7 @@
Name: "herp",
Created: "2014-09-25T13:10:02Z",
TenantID: "fcad67a6189847c4aecfa3c81a05783b",
- Metadata: map[string]interface{}{},
+ Metadata: map[string]string{},
SecurityGroups: []map[string]interface{}{
map[string]interface{}{
"name": "default",
@@ -408,7 +408,7 @@
Name: "derp",
Created: "2014-09-25T13:04:41Z",
TenantID: "fcad67a6189847c4aecfa3c81a05783b",
- Metadata: map[string]interface{}{},
+ Metadata: map[string]string{},
SecurityGroups: []map[string]interface{}{
map[string]interface{}{
"name": "default",
@@ -456,7 +456,7 @@
Name: "merp",
Created: "2014-09-25T13:04:41Z",
TenantID: "fcad67a6189847c4aecfa3c81a05783b",
- Metadata: map[string]interface{}{},
+ Metadata: map[string]string{},
SecurityGroups: []map[string]interface{}{
map[string]interface{}{
"name": "default",
@@ -603,6 +603,29 @@
})
}
+// HandleServerCreationWithMetadata sets up the test server to respond to a server creation request
+// with a given response.
+func HandleServerCreationWithMetadata(t *testing.T, response string) {
+ th.Mux.HandleFunc("/servers", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "POST")
+ th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
+ th.TestJSONRequest(t, r, `{
+ "server": {
+ "name": "derp",
+ "imageRef": "f90f6034-2570-4974-8351-6b49732ef2eb",
+ "flavorRef": "1",
+ "metadata": {
+ "abc": "def"
+ }
+ }
+ }`)
+
+ w.WriteHeader(http.StatusAccepted)
+ w.Header().Add("Content-Type", "application/json")
+ fmt.Fprintf(w, response)
+ })
+}
+
// HandleServerListSuccessfully sets up the test server to respond to a server List request.
func HandleServerListSuccessfully(t *testing.T) {
th.Mux.HandleFunc("/servers/detail", func(w http.ResponseWriter, r *http.Request) {