Update the acceptance tests to use pagination.
diff --git a/acceptance/openstack/storage_test.go b/acceptance/openstack/storage_test.go
index 833e5a3..9a9a65f 100644
--- a/acceptance/openstack/storage_test.go
+++ b/acceptance/openstack/storage_test.go
@@ -15,6 +15,7 @@
"github.com/rackspace/gophercloud/openstack/storage/v1/containers"
"github.com/rackspace/gophercloud/openstack/storage/v1/objects"
"github.com/rackspace/gophercloud/openstack/utils"
+ "github.com/rackspace/gophercloud/pagination"
)
var metadata = map[string]string{"gopher": "cloud"}
@@ -112,35 +113,41 @@
}
}()
- lr, err := containers.List(client, containers.ListOpts{
- Full: false,
+ cns := make([]string, 0, numContainers)
+ pager := containers.List(client, containers.ListOpts{Full: false})
+ err = pager.EachPage(func(page pagination.Page) (bool, error) {
+ names, err := containers.ExtractNames(page)
+ if err != nil {
+ return false, err
+ }
+
+ cns = append(cns, names...)
+
+ return true, nil
})
if err != nil {
- t.Error(err)
+ t.Fatal(err)
return
}
- cns, err := containers.ExtractNames(lr)
- if err != nil {
- t.Error(err)
- return
- }
+
if len(cns) != len(cNames) {
t.Errorf("Expected %d names and got %d", len(cNames), len(cns))
return
}
- lr, err = containers.List(client, containers.ListOpts{
- Full: true,
+ cis := make([]containers.Container, 0, numContainers)
+ pager = containers.List(client, containers.ListOpts{Full: true})
+ err = pager.EachPage(func(page pagination.Page) (bool, error) {
+ cisPage, err := containers.ExtractInfo(page)
+ if err != nil {
+ return false, err
+ }
+
+ cis = append(cis, cisPage...)
+
+ return true, nil
})
- if err != nil {
- t.Error(err)
- return
- }
- cis, err := containers.ExtractInfo(lr)
- if err != nil {
- t.Error(err)
- return
- }
+
if len(cis) != len(cNames) {
t.Errorf("Expected %d containers and got %d", len(cNames), len(cis))
return