More specific types for ObjectStorage response object fields (#74)
* more accurate types for objectstorage response object fields (e.g. ContentLength: string -> in64)
* containers unit tests for new field types
* more specific types for accounts headers fields
* update accounts unit tests
* download header unmarshal method and unit test
* object results unmarshal methods
diff --git a/openstack/objectstorage/v1/accounts/testing/fixtures.go b/openstack/objectstorage/v1/accounts/testing/fixtures.go
index a265199..fff3071 100644
--- a/openstack/objectstorage/v1/accounts/testing/fixtures.go
+++ b/openstack/objectstorage/v1/accounts/testing/fixtures.go
@@ -16,6 +16,7 @@
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Set("X-Account-Container-Count", "2")
+ w.Header().Set("X-Account-Object-Count", "5")
w.Header().Set("X-Account-Bytes-Used", "14")
w.Header().Set("X-Account-Meta-Subject", "books")
w.Header().Set("Date", "Fri, 17 Jan 2014 16:09:56 GMT")
diff --git a/openstack/objectstorage/v1/accounts/testing/requests_test.go b/openstack/objectstorage/v1/accounts/testing/requests_test.go
index cf3fe05..dc5d9de 100644
--- a/openstack/objectstorage/v1/accounts/testing/requests_test.go
+++ b/openstack/objectstorage/v1/accounts/testing/requests_test.go
@@ -2,20 +2,33 @@
import (
"testing"
+ "time"
+ "github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts"
th "github.com/gophercloud/gophercloud/testhelper"
fake "github.com/gophercloud/gophercloud/testhelper/client"
)
+var (
+ loc, _ = time.LoadLocation("GMT")
+)
+
func TestUpdateAccount(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleUpdateAccountSuccessfully(t)
options := &accounts.UpdateOpts{Metadata: map[string]string{"gophercloud-test": "accounts"}}
- _, err := accounts.Update(fake.ServiceClient(), options).Extract()
+ res := accounts.Update(fake.ServiceClient(), options)
+ th.AssertNoErr(t, res.Err)
+
+ expected := &accounts.UpdateHeader{
+ Date: gophercloud.JSONRFC1123(time.Date(2014, time.January, 17, 16, 9, 56, 0, loc)), // Fri, 17 Jan 2014 16:09:56 GMT
+ }
+ actual, err := res.Extract()
th.AssertNoErr(t, err)
+ th.CheckDeepEquals(t, expected, actual)
}
func TestGetAccount(t *testing.T) {
@@ -30,4 +43,14 @@
th.CheckDeepEquals(t, expectedMetadata, actualMetadata)
_, err := res.Extract()
th.AssertNoErr(t, err)
+
+ expected := &accounts.GetHeader{
+ ContainerCount: 2,
+ ObjectCount: 5,
+ BytesUsed: 14,
+ Date: gophercloud.JSONRFC1123(time.Date(2014, time.January, 17, 16, 9, 56, 0, loc)), // Fri, 17 Jan 2014 16:09:56 GMT
+ }
+ actual, err := res.Extract()
+ th.AssertNoErr(t, err)
+ th.CheckDeepEquals(t, expected, actual)
}