blob: e8f172dd18313cd066f38c7eb7eb1636df67b22e [file] [log] [blame]
Ash Wilson9d085a82014-10-03 13:05:03 -04001package tenants
2
3import (
Ash Wilson9d085a82014-10-03 13:05:03 -04004 "testing"
5
Ash Wilson9d085a82014-10-03 13:05:03 -04006 "github.com/rackspace/gophercloud/pagination"
7 th "github.com/rackspace/gophercloud/testhelper"
Ash Wilson55f89b82014-10-10 14:06:30 -04008 "github.com/rackspace/gophercloud/testhelper/client"
Ash Wilson9d085a82014-10-03 13:05:03 -04009)
10
Ash Wilson9d085a82014-10-03 13:05:03 -040011func TestListTenants(t *testing.T) {
12 th.SetupHTTP()
13 defer th.TeardownHTTP()
Ash Wilson55f89b82014-10-10 14:06:30 -040014 HandleListTenantsSuccessfully(t)
Ash Wilson9d085a82014-10-03 13:05:03 -040015
16 count := 0
Ash Wilson55f89b82014-10-10 14:06:30 -040017 err := List(client.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
Ash Wilson9d085a82014-10-03 13:05:03 -040018 count++
19
20 actual, err := ExtractTenants(page)
21 th.AssertNoErr(t, err)
22
Ash Wilson55f89b82014-10-10 14:06:30 -040023 th.CheckDeepEquals(t, ExpectedTenantSlice, actual)
Ash Wilson9d085a82014-10-03 13:05:03 -040024
25 return true, nil
26 })
27 th.AssertNoErr(t, err)
28 th.CheckEquals(t, count, 1)
29}