1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
package testing
import (
"testing"
"github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/services"
"github.com/gophercloud/gophercloud/pagination"
"github.com/gophercloud/gophercloud/testhelper"
"github.com/gophercloud/gophercloud/testhelper/client"
)
func TestListServices(t *testing.T) {
testhelper.SetupHTTP()
defer testhelper.TeardownHTTP()
HandleListSuccessfully(t)
pages := 0
err := services.List(client.ServiceClient(), services.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
pages++
actual, err := services.ExtractServices(page)
if err != nil {
return false, err
}
if len(actual) != 3 {
t.Fatalf("Expected 3 services, got %d", len(actual))
}
testhelper.CheckDeepEquals(t, FirstFakeService, actual[0])
testhelper.CheckDeepEquals(t, SecondFakeService, actual[1])
testhelper.CheckDeepEquals(t, ThirdFakeService, actual[2])
return true, nil
})
testhelper.AssertNoErr(t, err)
if pages != 1 {
t.Errorf("Expected 1 page, saw %d", pages)
}
}
|