Fixes to object storage docs and tests
diff --git a/openstack/objectstorage/v1/containers/doc.go b/openstack/objectstorage/v1/containers/doc.go
index 9b6ac17..5fed553 100644
--- a/openstack/objectstorage/v1/containers/doc.go
+++ b/openstack/objectstorage/v1/containers/doc.go
@@ -1,5 +1,8 @@
-/* The containers package defines operations performed on an object-storage container.
-
-Reference: http://developer.openstack.org/api-ref-objectstorage-v1.html#storage_container_services
-*/
+// Package containers contains functionality for working with Object Storage
+// container resources. A container serves as a logical namespace for objects
+// that are placed inside it - an object with the same name in two different
+// containers represents two different objects.
+//
+// In addition to containing objects, you can also use the container to control
+// access to objects by using an access control list (ACL).
package containers
diff --git a/openstack/objectstorage/v1/containers/requests_test.go b/openstack/objectstorage/v1/containers/requests_test.go
index 1ab09a9..09930d0 100644
--- a/openstack/objectstorage/v1/containers/requests_test.go
+++ b/openstack/objectstorage/v1/containers/requests_test.go
@@ -5,31 +5,20 @@
"net/http"
"testing"
- "github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
"github.com/rackspace/gophercloud/testhelper"
-)
-
-const (
- tokenId = "abcabcabcabc"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
)
var metadata = map[string]string{"gophercloud-test": "containers"}
-func serviceClient() *gophercloud.ServiceClient {
- return &gophercloud.ServiceClient{
- Provider: &gophercloud.ProviderClient{TokenID: tokenId},
- Endpoint: testhelper.Endpoint(),
- }
-}
-
func TestListContainerInfo(t *testing.T) {
testhelper.SetupHTTP()
defer testhelper.TeardownHTTP()
testhelper.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
testhelper.TestMethod(t, r, "GET")
- testhelper.TestHeader(t, r, "X-Auth-Token", tokenId)
+ testhelper.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
testhelper.TestHeader(t, r, "Accept", "application/json")
w.Header().Set("Content-Type", "application/json")
@@ -56,9 +45,9 @@
}
})
- client := serviceClient()
count := 0
- List(client, &ListOpts{Full: true}).EachPage(func(page pagination.Page) (bool, error) {
+
+ List(fake.ServiceClient(), &ListOpts{Full: true}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractInfo(page)
if err != nil {
@@ -95,7 +84,7 @@
testhelper.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
testhelper.TestMethod(t, r, "GET")
- testhelper.TestHeader(t, r, "X-Auth-Token", tokenId)
+ testhelper.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
testhelper.TestHeader(t, r, "Accept", "text/plain")
w.Header().Set("Content-Type", "text/plain")
@@ -111,9 +100,9 @@
}
})
- client := serviceClient()
count := 0
- List(client, &ListOpts{Full: false}).EachPage(func(page pagination.Page) (bool, error) {
+
+ List(fake.ServiceClient(), &ListOpts{Full: false}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractNames(page)
if err != nil {
@@ -139,13 +128,12 @@
testhelper.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) {
testhelper.TestMethod(t, r, "PUT")
- testhelper.TestHeader(t, r, "X-Auth-Token", tokenId)
+ testhelper.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
testhelper.TestHeader(t, r, "Accept", "application/json")
w.WriteHeader(http.StatusNoContent)
})
- client := serviceClient()
- _, err := Create(client, "testContainer", nil).ExtractHeaders()
+ _, err := Create(fake.ServiceClient(), "testContainer", nil).ExtractHeaders()
if err != nil {
t.Fatalf("Unexpected error creating container: %v", err)
}
@@ -157,13 +145,12 @@
testhelper.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) {
testhelper.TestMethod(t, r, "DELETE")
- testhelper.TestHeader(t, r, "X-Auth-Token", tokenId)
+ testhelper.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
testhelper.TestHeader(t, r, "Accept", "application/json")
w.WriteHeader(http.StatusNoContent)
})
- client := serviceClient()
- _, err := Delete(client, "testContainer").ExtractHeaders()
+ _, err := Delete(fake.ServiceClient(), "testContainer").ExtractHeaders()
if err != nil {
t.Fatalf("Unexpected error deleting container: %v", err)
}
@@ -175,13 +162,12 @@
testhelper.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) {
testhelper.TestMethod(t, r, "POST")
- testhelper.TestHeader(t, r, "X-Auth-Token", tokenId)
+ testhelper.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
testhelper.TestHeader(t, r, "Accept", "application/json")
w.WriteHeader(http.StatusNoContent)
})
- client := serviceClient()
- _, err := Update(client, "testContainer", nil).ExtractHeaders()
+ _, err := Update(fake.ServiceClient(), "testContainer", nil).ExtractHeaders()
if err != nil {
t.Fatalf("Unexpected error updating container metadata: %v", err)
}
@@ -193,13 +179,12 @@
testhelper.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) {
testhelper.TestMethod(t, r, "HEAD")
- testhelper.TestHeader(t, r, "X-Auth-Token", tokenId)
+ testhelper.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
testhelper.TestHeader(t, r, "Accept", "application/json")
w.WriteHeader(http.StatusNoContent)
})
- client := serviceClient()
- _, err := Get(client, "testContainer").ExtractMetadata()
+ _, err := Get(fake.ServiceClient(), "testContainer").ExtractMetadata()
if err != nil {
t.Fatalf("Unexpected error getting container metadata: %v", err)
}
diff --git a/openstack/objectstorage/v1/containers/results.go b/openstack/objectstorage/v1/containers/results.go
index 80425bd..3bf50fc 100644
--- a/openstack/objectstorage/v1/containers/results.go
+++ b/openstack/objectstorage/v1/containers/results.go
@@ -9,13 +9,20 @@
"github.com/rackspace/gophercloud/pagination"
)
+// Container represents a container resource.
type Container struct {
- Bytes int `json:"bytes" mapstructure:"bytes"`
- Count int `json:"count" mapstructure:"count"`
- Name string `json:"name" mapstructure:"name"`
+ // The total number of bytes stored in the container.
+ Bytes int `json:"bytes" mapstructure:"bytes"`
+
+ // The total number of objects stored in the container.
+ Count int `json:"count" mapstructure:"count"`
+
+ // The name of the container.
+ Name string `json:"name" mapstructure:"name"`
}
-// ListResult is a *http.Response that is returned from a call to the List function.
+// ContainerPage is the page returned by a pager when traversing over a
+// collection of containers.
type ContainerPage struct {
pagination.MarkerPageBase
}
@@ -124,14 +131,17 @@
return cr.Resp.Header, nil
}
+// CreateResult represents the result of a create operation.
type CreateResult struct {
commonResult
}
+// UpdateResult represents the result of an update operation.
type UpdateResult struct {
commonResult
}
+// DeleteResult represents the result of a delete operation.
type DeleteResult struct {
commonResult
}