Add support for OS flavors
diff --git a/openstack/db/v1/flavors/requests_test.go b/openstack/db/v1/flavors/requests_test.go
new file mode 100644
index 0000000..9ed9e59
--- /dev/null
+++ b/openstack/db/v1/flavors/requests_test.go
@@ -0,0 +1,96 @@
+package flavors
+
+import (
+ "testing"
+
+ "github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/pagination"
+ th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
+)
+
+func TestListFlavors(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+
+ HandleListFlavorsSuccessfully(t)
+
+ pages := 0
+ err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
+ pages++
+
+ actual, err := ExtractFlavors(page)
+ if err != nil {
+ return false, err
+ }
+
+ expected := []Flavor{
+ Flavor{
+ ID: 1,
+ Name: "m1.tiny",
+ RAM: 512,
+ Links: []gophercloud.Link{
+ gophercloud.Link{Href: "https://openstack.example.com/v1.0/1234/flavors/1", Rel: "self"},
+ gophercloud.Link{Href: "https://openstack.example.com/flavors/1", Rel: "bookmark"},
+ },
+ },
+ Flavor{
+ ID: 2,
+ Name: "m1.small",
+ RAM: 1024,
+ Links: []gophercloud.Link{
+ gophercloud.Link{Href: "https://openstack.example.com/v1.0/1234/flavors/2", Rel: "self"},
+ gophercloud.Link{Href: "https://openstack.example.com/flavors/2", Rel: "bookmark"},
+ },
+ },
+ Flavor{
+ ID: 3,
+ Name: "m1.medium",
+ RAM: 2048,
+ Links: []gophercloud.Link{
+ gophercloud.Link{Href: "https://openstack.example.com/v1.0/1234/flavors/3", Rel: "self"},
+ gophercloud.Link{Href: "https://openstack.example.com/flavors/3", Rel: "bookmark"},
+ },
+ },
+ Flavor{
+ ID: 4,
+ Name: "m1.large",
+ RAM: 4096,
+ Links: []gophercloud.Link{
+ gophercloud.Link{Href: "https://openstack.example.com/v1.0/1234/flavors/4", Rel: "self"},
+ gophercloud.Link{Href: "https://openstack.example.com/flavors/4", Rel: "bookmark"},
+ },
+ },
+ }
+
+ th.AssertDeepEquals(t, expected, actual)
+
+ return true, nil
+ })
+
+ th.AssertNoErr(t, err)
+ if pages != 1 {
+ t.Errorf("Expected one page, got %d", pages)
+ }
+}
+
+func TestGetFlavor(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+
+ HandleGetFlavorSuccessfully(t, "12345")
+
+ actual, err := Get(fake.ServiceClient(), "12345").Extract()
+ th.AssertNoErr(t, err)
+
+ expected := &Flavor{
+ ID: 1,
+ Name: "m1.tiny",
+ RAM: 512,
+ Links: []gophercloud.Link{
+ gophercloud.Link{Href: "https://openstack.example.com/v1.0/1234/flavors/1", Rel: "self"},
+ },
+ }
+
+ th.AssertDeepEquals(t, expected, actual)
+}