move unit tests into 'testing' directories
diff --git a/openstack/compute/v2/extensions/quotasets/requests.go b/openstack/compute/v2/extensions/quotasets/requests.go
index 52f0839..76beb17 100644
--- a/openstack/compute/v2/extensions/quotasets/requests.go
+++ b/openstack/compute/v2/extensions/quotasets/requests.go
@@ -1,7 +1,7 @@
package quotasets
import (
- "github.com/rackspace/gophercloud"
+ "github.com/gophercloud/gophercloud"
)
// Get returns public data about a previously created QuotaSet.
diff --git a/openstack/compute/v2/extensions/quotasets/requests_test.go b/openstack/compute/v2/extensions/quotasets/requests_test.go
deleted file mode 100644
index 5d766fa..0000000
--- a/openstack/compute/v2/extensions/quotasets/requests_test.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package quotasets
-
-import (
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
- "testing"
-)
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- HandleGetSuccessfully(t)
- actual, err := Get(client.ServiceClient(), FirstTenantID).Extract()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, &FirstQuotaSet, actual)
-}
diff --git a/openstack/compute/v2/extensions/quotasets/results.go b/openstack/compute/v2/extensions/quotasets/results.go
index cbf4d6b..f6c4e5a 100644
--- a/openstack/compute/v2/extensions/quotasets/results.go
+++ b/openstack/compute/v2/extensions/quotasets/results.go
@@ -1,39 +1,38 @@
package quotasets
import (
- "github.com/mitchellh/mapstructure"
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
+ "github.com/gophercloud/gophercloud"
+ "github.com/gophercloud/gophercloud/pagination"
)
// QuotaSet is a set of operational limits that allow for control of compute usage.
type QuotaSet struct {
//ID is tenant associated with this quota_set
- ID string `mapstructure:"id"`
+ ID string `json:"id"`
//FixedIps is number of fixed ips alloted this quota_set
- FixedIps int `mapstructure:"fixed_ips"`
+ FixedIps int `json:"fixed_ips"`
// FloatingIps is number of floating ips alloted this quota_set
- FloatingIps int `mapstructure:"floating_ips"`
+ FloatingIps int `json:"floating_ips"`
// InjectedFileContentBytes is content bytes allowed for each injected file
- InjectedFileContentBytes int `mapstructure:"injected_file_content_bytes"`
+ InjectedFileContentBytes int `json:"injected_file_content_bytes"`
// InjectedFilePathBytes is allowed bytes for each injected file path
- InjectedFilePathBytes int `mapstructure:"injected_file_path_bytes"`
+ InjectedFilePathBytes int `json:"injected_file_path_bytes"`
// InjectedFiles is injected files allowed for each project
- InjectedFiles int `mapstructure:"injected_files"`
+ InjectedFiles int `json:"injected_files"`
// KeyPairs is number of ssh keypairs
- KeyPairs int `mapstructure:"keypairs"`
+ KeyPairs int `json:"keypairs"`
// MetadataItems is number of metadata items allowed for each instance
- MetadataItems int `mapstructure:"metadata_items"`
+ MetadataItems int `json:"metadata_items"`
// Ram is megabytes allowed for each instance
- Ram int `mapstructure:"ram"`
+ Ram int `json:"ram"`
// SecurityGroupRules is rules allowed for each security group
- SecurityGroupRules int `mapstructure:"security_group_rules"`
+ SecurityGroupRules int `json:"security_group_rules"`
// SecurityGroups security groups allowed for each project
- SecurityGroups int `mapstructure:"security_groups"`
+ SecurityGroups int `json:"security_groups"`
// Cores is number of instance cores allowed for each project
- Cores int `mapstructure:"cores"`
+ Cores int `json:"cores"`
// Instances is number of instances allowed for each project
- Instances int `mapstructure:"instances"`
+ Instances int `json:"instances"`
}
// QuotaSetPage stores a single, only page of QuotaSet results from a List call.
@@ -48,17 +47,12 @@
}
// ExtractQuotaSets interprets a page of results as a slice of QuotaSets.
-func ExtractQuotaSets(page pagination.Page) ([]QuotaSet, error) {
- var resp struct {
- QuotaSets []QuotaSet `mapstructure:"quotas"`
+func ExtractQuotaSets(r pagination.Page) ([]QuotaSet, error) {
+ var s struct {
+ QuotaSets []QuotaSet `json:"quotas"`
}
-
- err := mapstructure.Decode(page.(QuotaSetPage).Body, &resp)
- results := make([]QuotaSet, len(resp.QuotaSets))
- for i, q := range resp.QuotaSets {
- results[i] = q
- }
- return results, err
+ err := (r.(QuotaSetPage)).ExtractInto(&s)
+ return s.QuotaSets, err
}
type quotaResult struct {
@@ -67,16 +61,11 @@
// Extract is a method that attempts to interpret any QuotaSet resource response as a QuotaSet struct.
func (r quotaResult) Extract() (*QuotaSet, error) {
- if r.Err != nil {
- return nil, r.Err
+ var s struct {
+ QuotaSet *QuotaSet `json:"quota_set"`
}
-
- var res struct {
- QuotaSet *QuotaSet `json:"quota_set" mapstructure:"quota_set"`
- }
-
- err := mapstructure.Decode(r.Body, &res)
- return res.QuotaSet, err
+ err := r.ExtractInto(&s)
+ return s.QuotaSet, err
}
// GetResult is the response from a Get operation. Call its Extract method to interpret it
diff --git a/openstack/compute/v2/extensions/quotasets/testing/doc.go b/openstack/compute/v2/extensions/quotasets/testing/doc.go
new file mode 100644
index 0000000..7603f83
--- /dev/null
+++ b/openstack/compute/v2/extensions/quotasets/testing/doc.go
@@ -0,0 +1 @@
+package testing
diff --git a/openstack/compute/v2/extensions/quotasets/fixtures.go b/openstack/compute/v2/extensions/quotasets/testing/fixtures.go
similarity index 84%
rename from openstack/compute/v2/extensions/quotasets/fixtures.go
rename to openstack/compute/v2/extensions/quotasets/testing/fixtures.go
index c1bb4ea..3fef872 100644
--- a/openstack/compute/v2/extensions/quotasets/fixtures.go
+++ b/openstack/compute/v2/extensions/quotasets/testing/fixtures.go
@@ -1,14 +1,13 @@
-// +build fixtures
-
-package quotasets
+package testing
import (
"fmt"
"net/http"
"testing"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
+ "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/quotasets"
+ th "github.com/gophercloud/gophercloud/testhelper"
+ "github.com/gophercloud/gophercloud/testhelper/client"
)
// GetOutput is a sample response to a Get call.
@@ -32,7 +31,7 @@
const FirstTenantID = "555544443333222211110000ffffeeee"
// FirstQuotaSet is the first result in ListOutput.
-var FirstQuotaSet = QuotaSet{
+var FirstQuotaSet = quotasets.QuotaSet{
FixedIps: 0,
FloatingIps: 0,
InjectedFileContentBytes: 10240,
diff --git a/openstack/compute/v2/extensions/quotasets/testing/requests_test.go b/openstack/compute/v2/extensions/quotasets/testing/requests_test.go
new file mode 100644
index 0000000..8fc1fd4
--- /dev/null
+++ b/openstack/compute/v2/extensions/quotasets/testing/requests_test.go
@@ -0,0 +1,18 @@
+package testing
+
+import (
+ "testing"
+
+ "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/quotasets"
+ th "github.com/gophercloud/gophercloud/testhelper"
+ "github.com/gophercloud/gophercloud/testhelper/client"
+)
+
+func TestGet(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandleGetSuccessfully(t)
+ actual, err := quotasets.Get(client.ServiceClient(), FirstTenantID).Extract()
+ th.AssertNoErr(t, err)
+ th.CheckDeepEquals(t, &FirstQuotaSet, actual)
+}
diff --git a/openstack/compute/v2/extensions/quotasets/urls.go b/openstack/compute/v2/extensions/quotasets/urls.go
index c04d941..e910376 100644
--- a/openstack/compute/v2/extensions/quotasets/urls.go
+++ b/openstack/compute/v2/extensions/quotasets/urls.go
@@ -1,6 +1,6 @@
package quotasets
-import "github.com/rackspace/gophercloud"
+import "github.com/gophercloud/gophercloud"
const resourcePath = "os-quota-sets"
diff --git a/openstack/compute/v2/extensions/quotasets/urls_test.go b/openstack/compute/v2/extensions/quotasets/urls_test.go
deleted file mode 100644
index f19a6ad..0000000
--- a/openstack/compute/v2/extensions/quotasets/urls_test.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package quotasets
-
-import (
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestGetURL(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- c := client.ServiceClient()
-
- th.CheckEquals(t, c.Endpoint+"os-quota-sets/wat", getURL(c, "wat"))
-}