Refactor common code from openstack tests.
diff --git a/rackspace/compute/v2/servers/delegate_test.go b/rackspace/compute/v2/servers/delegate_test.go
index c1521be..8c034cf 100644
--- a/rackspace/compute/v2/servers/delegate_test.go
+++ b/rackspace/compute/v2/servers/delegate_test.go
@@ -39,25 +39,9 @@
func TestCreateServer(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
+ os.HandleServerCreationSuccessfully(t, CreateOutput)
- 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"
- }
- }`)
-
- w.WriteHeader(http.StatusAccepted)
- w.Header().Add("Content-Type", "application/json")
- fmt.Fprintf(w, CreateOutput)
- })
-
- client := client.ServiceClient()
- actual, err := Create(client, os.CreateOpts{
+ actual, err := Create(client.ServiceClient(), os.CreateOpts{
Name: "derp",
ImageRef: "f90f6034-2570-4974-8351-6b49732ef2eb",
FlavorRef: "1",
@@ -67,6 +51,15 @@
th.CheckDeepEquals(t, &CreatedServer, actual)
}
+func TestDeleteServer(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ os.HandleServerDeletionSuccessfully(t)
+
+ err := Delete(client.ServiceClient(), "asdfasdfasdf")
+ th.AssertNoErr(t, err)
+}
+
func TestGetServer(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()