move unit tests into 'testing' directories
diff --git a/openstack/db/v1/flavors/testing/doc.go b/openstack/db/v1/flavors/testing/doc.go
new file mode 100644
index 0000000..7603f83
--- /dev/null
+++ b/openstack/db/v1/flavors/testing/doc.go
@@ -0,0 +1 @@
+package testing
diff --git a/openstack/db/v1/flavors/testing/fixtures.go b/openstack/db/v1/flavors/testing/fixtures.go
new file mode 100644
index 0000000..b2b2d5f
--- /dev/null
+++ b/openstack/db/v1/flavors/testing/fixtures.go
@@ -0,0 +1,50 @@
+package testing
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/gophercloud/gophercloud/testhelper/fixture"
+)
+
+const flavor = `
+{
+ "id": %d,
+ "links": [
+ {
+ "href": "https://openstack.example.com/v1.0/1234/flavors/%d",
+ "rel": "self"
+ },
+ {
+ "href": "https://openstack.example.com/flavors/%d",
+ "rel": "bookmark"
+ }
+ ],
+ "name": "%s",
+ "ram": %d
+}
+`
+
+var (
+ flavorID = "{flavorID}"
+ _baseURL = "/flavors"
+ resURL = "/flavors/" + flavorID
+)
+
+var (
+ flavor1 = fmt.Sprintf(flavor, 1, 1, 1, "m1.tiny", 512)
+ flavor2 = fmt.Sprintf(flavor, 2, 2, 2, "m1.small", 1024)
+ flavor3 = fmt.Sprintf(flavor, 3, 3, 3, "m1.medium", 2048)
+ flavor4 = fmt.Sprintf(flavor, 4, 4, 4, "m1.large", 4096)
+
+ listFlavorsResp = fmt.Sprintf(`{"flavors":[%s, %s, %s, %s]}`, flavor1, flavor2, flavor3, flavor4)
+ getFlavorResp = fmt.Sprintf(`{"flavor": %s}`, flavor1)
+)
+
+func HandleList(t *testing.T) {
+ fixture.SetupHandler(t, _baseURL, "GET", "", listFlavorsResp, 200)
+}
+
+func HandleGet(t *testing.T) {
+ fixture.SetupHandler(t, resURL, "GET", "", getFlavorResp, 200)
+}
diff --git a/openstack/db/v1/flavors/testing/requests_test.go b/openstack/db/v1/flavors/testing/requests_test.go
new file mode 100644
index 0000000..cbc0edd
--- /dev/null
+++ b/openstack/db/v1/flavors/testing/requests_test.go
@@ -0,0 +1,92 @@
+package testing
+
+import (
+ "testing"
+
+ "github.com/gophercloud/gophercloud"
+ "github.com/gophercloud/gophercloud/openstack/db/v1/flavors"
+ "github.com/gophercloud/gophercloud/pagination"
+ th "github.com/gophercloud/gophercloud/testhelper"
+ fake "github.com/gophercloud/gophercloud/testhelper/client"
+)
+
+func TestListFlavors(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandleList(t)
+
+ pages := 0
+ err := flavors.List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
+ pages++
+
+ actual, err := flavors.ExtractFlavors(page)
+ if err != nil {
+ return false, err
+ }
+
+ expected := []flavors.Flavor{
+ {
+ ID: 1,
+ Name: "m1.tiny",
+ RAM: 512,
+ Links: []gophercloud.Link{
+ {Href: "https://openstack.example.com/v1.0/1234/flavors/1", Rel: "self"},
+ {Href: "https://openstack.example.com/flavors/1", Rel: "bookmark"},
+ },
+ },
+ {
+ ID: 2,
+ Name: "m1.small",
+ RAM: 1024,
+ Links: []gophercloud.Link{
+ {Href: "https://openstack.example.com/v1.0/1234/flavors/2", Rel: "self"},
+ {Href: "https://openstack.example.com/flavors/2", Rel: "bookmark"},
+ },
+ },
+ {
+ ID: 3,
+ Name: "m1.medium",
+ RAM: 2048,
+ Links: []gophercloud.Link{
+ {Href: "https://openstack.example.com/v1.0/1234/flavors/3", Rel: "self"},
+ {Href: "https://openstack.example.com/flavors/3", Rel: "bookmark"},
+ },
+ },
+ {
+ ID: 4,
+ Name: "m1.large",
+ RAM: 4096,
+ Links: []gophercloud.Link{
+ {Href: "https://openstack.example.com/v1.0/1234/flavors/4", Rel: "self"},
+ {Href: "https://openstack.example.com/flavors/4", Rel: "bookmark"},
+ },
+ },
+ }
+
+ th.AssertDeepEquals(t, expected, actual)
+ return true, nil
+ })
+
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, 1, pages)
+}
+
+func TestGetFlavor(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandleGet(t)
+
+ actual, err := flavors.Get(fake.ServiceClient(), flavorID).Extract()
+ th.AssertNoErr(t, err)
+
+ expected := &flavors.Flavor{
+ ID: 1,
+ Name: "m1.tiny",
+ RAM: 512,
+ Links: []gophercloud.Link{
+ {Href: "https://openstack.example.com/v1.0/1234/flavors/1", Rel: "self"},
+ },
+ }
+
+ th.AssertDeepEquals(t, expected, actual)
+}