Get instance :rocket:
diff --git a/openstack/db/v1/instances/requests_test.go b/openstack/db/v1/instances/requests_test.go
index 236deae..6c0825b 100644
--- a/openstack/db/v1/instances/requests_test.go
+++ b/openstack/db/v1/instances/requests_test.go
@@ -9,6 +9,28 @@
fake "github.com/rackspace/gophercloud/testhelper/client"
)
+var instanceID = "d4603f69-ec7e-4e9b-803f-600b9205576f"
+
+var expectedInstance = &Instance{
+ Created: "2014-02-13T21:47:13",
+ Updated: "2014-02-13T21:47:13",
+ Flavor: Flavor{
+ ID: "1",
+ Links: []gophercloud.Link{
+ gophercloud.Link{Href: "https://my-openstack.com/v1.0/1234/flavors/1", Rel: "self"},
+ gophercloud.Link{Href: "https://my-openstack.com/v1.0/1234/flavors/1", Rel: "bookmark"},
+ },
+ },
+ Hostname: "e09ad9a3f73309469cf1f43d11e79549caf9acf2.my-openstack.com",
+ ID: instanceID,
+ Links: []gophercloud.Link{
+ gophercloud.Link{Href: "https://my-openstack.com/v1.0/1234/instances/1", Rel: "self"},
+ },
+ Name: "json_rack_instance",
+ Status: "BUILD",
+ Volume: Volume{Size: 2},
+}
+
func TestCreate(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
@@ -36,28 +58,8 @@
instance, err := Create(fake.ServiceClient(), opts).Extract()
- expected := &Instance{
- Created: "2014-02-13T21:47:13",
- Updated: "2014-02-13T21:47:13",
- Flavor: Flavor{
- ID: "1",
- Links: []gophercloud.Link{
- gophercloud.Link{Href: "https://my-openstack.com/v1.0/1234/flavors/1", Rel: "self"},
- gophercloud.Link{Href: "https://my-openstack.com/v1.0/1234/flavors/1", Rel: "bookmark"},
- },
- },
- Hostname: "e09ad9a3f73309469cf1f43d11e79549caf9acf2.my-openstack.com",
- ID: "d4603f69-ec7e-4e9b-803f-600b9205576f",
- Links: []gophercloud.Link{
- gophercloud.Link{Href: "https://my-openstack.com/v1.0/1234/instances/1", Rel: "self"},
- },
- Name: "json_rack_instance",
- Status: "BUILD",
- Volume: Volume{Size: 2},
- }
-
th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, expected, instance)
+ th.AssertDeepEquals(t, expectedInstance, instance)
}
func TestInstanceList(t *testing.T) {
@@ -106,3 +108,15 @@
t.Errorf("Expected 1 page, saw %d", pages)
}
}
+
+func TestGetInstance(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+
+ HandleGetInstanceSuccessfully(t, instanceID)
+
+ instance, err := Get(fake.ServiceClient(), instanceID).Extract()
+
+ th.AssertNoErr(t, err)
+ th.AssertDeepEquals(t, instance, expectedInstance)
+}