fix coverage script from masking unit test failures (#265)
* add 'set -e' line to fail on error
* create Unmarshal method for DefaultSecRule
* fix portsbinding 'update' unit test
* go fmt
* remove line from debugging
diff --git a/openstack/compute/v2/extensions/defsecrules/results.go b/openstack/compute/v2/extensions/defsecrules/results.go
index 61b918d..f990c99 100644
--- a/openstack/compute/v2/extensions/defsecrules/results.go
+++ b/openstack/compute/v2/extensions/defsecrules/results.go
@@ -1,6 +1,8 @@
package defsecrules
import (
+ "encoding/json"
+
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/secgroups"
"github.com/gophercloud/gophercloud/pagination"
@@ -10,6 +12,16 @@
// normal security rule.
type DefaultRule secgroups.Rule
+func (r *DefaultRule) UnmarshalJSON(b []byte) error {
+ var s secgroups.Rule
+ err := json.Unmarshal(b, &s)
+ if err != nil {
+ return err
+ }
+ *r = DefaultRule(s)
+ return nil
+}
+
// DefaultRulePage is a single page of a DefaultRule collection.
type DefaultRulePage struct {
pagination.SinglePageBase
diff --git a/openstack/compute/v2/extensions/quotasets/requests.go b/openstack/compute/v2/extensions/quotasets/requests.go
index 64fc8ff..bb9cb22 100644
--- a/openstack/compute/v2/extensions/quotasets/requests.go
+++ b/openstack/compute/v2/extensions/quotasets/requests.go
@@ -74,6 +74,3 @@
return gophercloud.BuildRequestBody(opts, "quota_set")
}
-
-
-
diff --git a/openstack/compute/v2/extensions/quotasets/testing/fixtures.go b/openstack/compute/v2/extensions/quotasets/testing/fixtures.go
index 0945f9b..79305a7 100644
--- a/openstack/compute/v2/extensions/quotasets/testing/fixtures.go
+++ b/openstack/compute/v2/extensions/quotasets/testing/fixtures.go
@@ -2,12 +2,12 @@
import (
"fmt"
- "net/http"
- "testing"
+ "github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/quotasets"
th "github.com/gophercloud/gophercloud/testhelper"
"github.com/gophercloud/gophercloud/testhelper/client"
- "github.com/gophercloud/gophercloud"
+ "net/http"
+ "testing"
)
// GetOutput is a sample response to a Get call.
@@ -45,18 +45,16 @@
SecurityGroups: 10,
Cores: 200,
Instances: 25,
- ServerGroups: 2,
+ ServerGroups: 2,
ServerGroupMembers: 3,
}
-
//The expected update Body. Is also returned by PUT request
const UpdateOutput = `{"quota_set":{"cores":200,"fixed_ips":0,"floating_ips":0,"injected_file_content_bytes":10240,"injected_file_path_bytes":255,"injected_files":5,"instances":25,"key_pairs":10,"metadata_items":128,"ram":200000,"security_group_rules":20,"security_groups":10,"server_groups":2,"server_group_members":3}}`
//The expected partialupdate Body. Is also returned by PUT request
const PartialUpdateBody = `{"quota_set":{"cores":200, "force":true}}`
-
//Result of Quota-update
var UpdatedQuotaSet = quotasets.UpdateOpts{
FixedIps: gophercloud.IntToPointer(0),
@@ -71,7 +69,7 @@
SecurityGroups: gophercloud.IntToPointer(10),
Cores: gophercloud.IntToPointer(200),
Instances: gophercloud.IntToPointer(25),
- ServerGroups: gophercloud.IntToPointer(2),
+ ServerGroups: gophercloud.IntToPointer(2),
ServerGroupMembers: gophercloud.IntToPointer(3),
}
@@ -91,7 +89,7 @@
th.Mux.HandleFunc("/os-quota-sets/"+FirstTenantID, func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
- th.TestJSONRequest(t,r,UpdateOutput)
+ th.TestJSONRequest(t, r, UpdateOutput)
w.Header().Add("Content-Type", "application/json")
fmt.Fprintf(w, UpdateOutput)
})
@@ -102,7 +100,7 @@
th.Mux.HandleFunc("/os-quota-sets/"+FirstTenantID, func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
- th.TestJSONRequest(t,r,PartialUpdateBody)
+ th.TestJSONRequest(t, r, PartialUpdateBody)
w.Header().Add("Content-Type", "application/json")
fmt.Fprintf(w, UpdateOutput)
})
@@ -113,8 +111,8 @@
th.Mux.HandleFunc("/os-quota-sets/"+FirstTenantID, func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "DELETE")
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
- th.TestBody(t,r,"")
+ th.TestBody(t, r, "")
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(202)
})
-}
\ No newline at end of file
+}
diff --git a/openstack/compute/v2/extensions/quotasets/testing/requests_test.go b/openstack/compute/v2/extensions/quotasets/testing/requests_test.go
index e63f6aa..0193f97 100644
--- a/openstack/compute/v2/extensions/quotasets/testing/requests_test.go
+++ b/openstack/compute/v2/extensions/quotasets/testing/requests_test.go
@@ -3,11 +3,11 @@
import (
"testing"
+ "errors"
+ "github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/quotasets"
th "github.com/gophercloud/gophercloud/testhelper"
"github.com/gophercloud/gophercloud/testhelper/client"
- "github.com/gophercloud/gophercloud"
- "errors"
)
func TestGet(t *testing.T) {
@@ -32,7 +32,7 @@
th.SetupHTTP()
defer th.TeardownHTTP()
HandlePartialPutSuccessfully(t)
- opts := quotasets.UpdateOpts{Cores:gophercloud.IntToPointer(200), Force:true}
+ opts := quotasets.UpdateOpts{Cores: gophercloud.IntToPointer(200), Force: true}
actual, err := quotasets.Update(client.ServiceClient(), FirstTenantID, opts).Extract()
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, &FirstQuotaSet, actual)
@@ -46,20 +46,19 @@
th.AssertNoErr(t, err)
}
-type ErrorUpdateOpts quotasets.UpdateOpts;
+type ErrorUpdateOpts quotasets.UpdateOpts
func (opts ErrorUpdateOpts) ToComputeQuotaUpdateMap() (map[string]interface{}, error) {
return nil, errors.New("This is an error")
}
-func TestErrorInToComputeQuotaUpdateMap(t *testing.T){
+func TestErrorInToComputeQuotaUpdateMap(t *testing.T) {
opts := &ErrorUpdateOpts{}
th.SetupHTTP()
defer th.TeardownHTTP()
HandlePutSuccessfully(t)
_, err := quotasets.Update(client.ServiceClient(), FirstTenantID, opts).Extract()
- if err == nil{
+ if err == nil {
t.Fatal("Error handling failed")
}
}
-
diff --git a/openstack/compute/v2/extensions/quotasets/urls.go b/openstack/compute/v2/extensions/quotasets/urls.go
index 4e15613..64190e9 100644
--- a/openstack/compute/v2/extensions/quotasets/urls.go
+++ b/openstack/compute/v2/extensions/quotasets/urls.go
@@ -18,4 +18,4 @@
func deleteURL(c *gophercloud.ServiceClient, tenantID string) string {
return getURL(c, tenantID)
-}
\ No newline at end of file
+}
diff --git a/openstack/compute/v2/images/results.go b/openstack/compute/v2/images/results.go
index a55b8f1..1090327 100644
--- a/openstack/compute/v2/images/results.go
+++ b/openstack/compute/v2/images/results.go
@@ -45,7 +45,7 @@
Status string
Updated string
-
+
Metadata map[string]string
}