Server creation test.
diff --git a/openstack/compute/v2/servers/data_test.go b/openstack/compute/v2/servers/data_test.go
index 16a5433..d3a0ee0 100644
--- a/openstack/compute/v2/servers/data_test.go
+++ b/openstack/compute/v2/servers/data_test.go
@@ -150,7 +150,7 @@
}
`
- serverGetBody = `
+ singleServerBody = `
{
"server": {
"status": "ACTIVE",
@@ -169,11 +169,11 @@
},
"links": [
{
- "href": "http://104.130.131.164:8774/v2/e1a1494482b947f5a270acb6e5963aa3/servers/9e5476bd-a4ec-4653-93d6-72c93aa682ba",
+ "href": "http://104.130.131.164:8774/v2/fcad67a6189847c4aecfa3c81a05783b/servers/9e5476bd-a4ec-4653-93d6-72c93aa682ba",
"rel": "self"
},
{
- "href": "http://104.130.131.164:8774/e1a1494482b947f5a270acb6e5963aa3/servers/9e5476bd-a4ec-4653-93d6-72c93aa682ba",
+ "href": "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/servers/9e5476bd-a4ec-4653-93d6-72c93aa682ba",
"rel": "bookmark"
}
],
@@ -182,7 +182,7 @@
"id": "f90f6034-2570-4974-8351-6b49732ef2eb",
"links": [
{
- "href": "http://104.130.131.164:8774/e1a1494482b947f5a270acb6e5963aa3/images/f90f6034-2570-4974-8351-6b49732ef2eb",
+ "href": "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/images/f90f6034-2570-4974-8351-6b49732ef2eb",
"rel": "bookmark"
}
]
@@ -196,7 +196,7 @@
"id": "1",
"links": [
{
- "href": "http://104.130.131.164:8774/e1a1494482b947f5a270acb6e5963aa3/flavors/1",
+ "href": "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/flavors/1",
"rel": "bookmark"
}
]
diff --git a/openstack/compute/v2/servers/requests_test.go b/openstack/compute/v2/servers/requests_test.go
index 4499660..1cece86 100644
--- a/openstack/compute/v2/servers/requests_test.go
+++ b/openstack/compute/v2/servers/requests_test.go
@@ -70,7 +70,39 @@
func TestCreateServer(t *testing.T) {
testhelper.SetupHTTP()
defer testhelper.TeardownHTTP()
- t.Error("Pending")
+
+ testhelper.Mux.HandleFunc("/servers", func(w http.ResponseWriter, r *http.Request) {
+ testhelper.TestMethod(t, r, "POST")
+ testhelper.TestHeader(t, r, "X-Auth-Token", tokenID)
+ testhelper.TestJSONRequest(t, r, `{
+ "server": {
+ "name": "derp",
+ "imageRef": "f90f6034-2570-4974-8351-6b49732ef2eb",
+ "flavorRef": "1"
+ }
+ }`)
+
+ w.WriteHeader(http.StatusAccepted)
+ w.Header().Add("Content-Type", "application/json")
+ fmt.Fprintf(w, singleServerBody)
+ })
+
+ client := serviceClient()
+ result, err := Create(client, map[string]interface{}{
+ "name": "derp",
+ "imageRef": "f90f6034-2570-4974-8351-6b49732ef2eb",
+ "flavorRef": "1",
+ })
+ if err != nil {
+ t.Fatalf("Unexpected Create error: %v", err)
+ }
+
+ actual, err := ExtractServer(result)
+ if err != nil {
+ t.Fatalf("Unexpected ExtractServer error: %v", err)
+ }
+
+ equalServers(t, serverDerp, *actual)
}
func TestDeleteServer(t *testing.T) {