Finalizing acceptance tests and modifying fields
diff --git a/acceptance/openstack/networking/v2/extensions/quota_test.go b/acceptance/openstack/networking/v2/extensions/quota_test.go
index 1392318..f855046 100644
--- a/acceptance/openstack/networking/v2/extensions/quota_test.go
+++ b/acceptance/openstack/networking/v2/extensions/quota_test.go
@@ -1,17 +1,45 @@
-// +build acceptance networking extensions
+// +build acceptance networking quotas
+
+package extensions
import (
"testing"
+
+ base "github.com/rackspace/gophercloud/acceptance/openstack/networking/v2"
+ "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/quotas"
)
-func TestGet(t *testing.T) {
+func TestQuotas(t *testing.T) {
+ base.Setup()
+ defer Teardown()
+ setQuotas(t)
+ getQuotas(t)
+ resetQuotas(t)
}
-func TestUpdate(t *testing.T) {
-
+func getQuotas(t *testing.T) {
+ qs, err := quotas.Get(base.Client).Extract()
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, qs.Subnet, 10)
+ th.AssertEquals(t, qs.Router, 10)
+ th.AssertEquals(t, qs.Port, 50)
+ th.AssertEquals(t, qs.Network, 10)
+ th.AssertEquals(t, qs.FloatingIP, 50)
}
-func TestReset(t *testing.T) {
+func setQuotas(t *testing.T) {
+ i10, i20, i30 := 10, 20, 30
+ opts := UpdateOpts{Member: &i30, Pool: &i20, SecGroup: &i20, HealthMonitor: &i10}
+ qs, err := quotas.Update(base.Client).Extract()
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, qs.Member, 30)
+ th.AssertEquals(t, qs.Pool, 20)
+ th.AssertEquals(t, qs.SecGroup, 20)
+ th.AssertEquals(t, qs.HealthMonitor, 10)
+}
+func resetQuotas(t *testing.T) {
+ res := quotas.Reset(base.Client)
+ th.AssertNoErr(t, res.Err)
}
diff --git a/openstack/networking/v2/extensions/quotas/requests.go b/openstack/networking/v2/extensions/quotas/requests.go
index f16c440..df16dd9 100755
--- a/openstack/networking/v2/extensions/quotas/requests.go
+++ b/openstack/networking/v2/extensions/quotas/requests.go
@@ -8,10 +8,10 @@
func Get(c *gophercloud.ServiceClient) GetResult {
var res GetResult
_, err := perigee.Request("GET", rootURL(c), perigee.Options{
- Results: &res.resp,
+ Results: &res.Resp,
MoreHeaders: c.Provider.AuthenticatedHeaders(),
})
- res.err = err
+ res.Err = err
return res
}
@@ -66,11 +66,10 @@
_, err := perigee.Request("PUT", rootURL(c), perigee.Options{
MoreHeaders: c.Provider.AuthenticatedHeaders(),
ReqBody: &reqBody,
- Results: &res.resp,
+ Results: &res.Resp,
OkCodes: []int{200},
})
- res.err = err
-
+ res.Err = err
return res
}
@@ -80,6 +79,6 @@
MoreHeaders: c.Provider.AuthenticatedHeaders(),
OkCodes: []int{204},
})
- res.err = err
+ res.Err = err
return res
}
diff --git a/openstack/networking/v2/extensions/quotas/requests_test.go b/openstack/networking/v2/extensions/quotas/requests_test.go
index 1157c49..5809a96 100755
--- a/openstack/networking/v2/extensions/quotas/requests_test.go
+++ b/openstack/networking/v2/extensions/quotas/requests_test.go
@@ -112,5 +112,5 @@
})
res := Reset(serviceClient())
- th.AssertNoErr(t, res.err)
+ th.AssertNoErr(t, res.Err)
}
diff --git a/openstack/networking/v2/extensions/quotas/results.go b/openstack/networking/v2/extensions/quotas/results.go
index 5c73e57..23bed9e 100755
--- a/openstack/networking/v2/extensions/quotas/results.go
+++ b/openstack/networking/v2/extensions/quotas/results.go
@@ -4,33 +4,35 @@
"fmt"
"github.com/mitchellh/mapstructure"
+ "github.com/rackspace/gophercloud"
)
type Quota struct {
- Subnet int `json:"subnet"`
- Router int `json:"router"`
- Port int `json:"port"`
- Network int `json:"network"`
- FloatingIP int `json:"floatingip"`
+ Subnet int `json:"subnet"`
+ Router int `json:"router"`
+ Port int `json:"port"`
+ Network int `json:"network"`
+ FloatingIP int `json:"floatingip"`
+ HealthMonitor int `json:"health_monitor"`
+ SecGroupRule int `json:"security_group_rule"`
+ SecGroup int `json:"security_group"`
+ VIP int `json:"vip"`
+ Member int `json:"member"`
+ Pool int `json:"pool"`
}
-type commonResult struct {
- resp map[string]interface{}
- err error
-}
+type commonResult gophercloud.CommonResult
-type GetResult commonResult
-
-func (r GetResult) Extract() (*Quota, error) {
- if r.err != nil {
- return nil, r.err
+func (r commonResult) Extract() (*Quota, error) {
+ if r.Err != nil {
+ return nil, r.Err
}
var res struct {
Quota *Quota `json:"quota"`
}
- err := mapstructure.Decode(r.resp, &res)
+ err := mapstructure.Decode(r.Resp, &res)
if err != nil {
return nil, fmt.Errorf("Error decoding Neutron quotas: %v", err)
}
@@ -38,25 +40,12 @@
return res.Quota, nil
}
+type GetResult struct {
+ commonResult
+}
+
type UpdateResult struct {
commonResult
}
-func (r UpdateResult) Extract() (*Quota, error) {
- if r.err != nil {
- return nil, r.err
- }
-
- var res struct {
- Quota *Quota `json:"quota"`
- }
-
- err := mapstructure.Decode(r.resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron quotas: %v", err)
- }
-
- return res.Quota, nil
-}
-
type DeleteResult commonResult