Ash Wilson | 94af38d | 2014-10-10 14:07:02 -0400 | [diff] [blame] | 1 | package tenants |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | os "github.com/rackspace/gophercloud/openstack/identity/v2/tenants" |
| 7 | "github.com/rackspace/gophercloud/pagination" |
| 8 | th "github.com/rackspace/gophercloud/testhelper" |
| 9 | fake "github.com/rackspace/gophercloud/testhelper/client" |
| 10 | ) |
| 11 | |
| 12 | func TestListTenants(t *testing.T) { |
| 13 | th.SetupHTTP() |
| 14 | defer th.TeardownHTTP() |
| 15 | os.HandleListTenantsSuccessfully(t) |
| 16 | |
| 17 | count := 0 |
| 18 | err := List(fake.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) { |
| 19 | actual, err := ExtractTenants(page) |
| 20 | th.AssertNoErr(t, err) |
| 21 | th.CheckDeepEquals(t, os.ExpectedTenantSlice, actual) |
| 22 | |
| 23 | count++ |
| 24 | return true, nil |
| 25 | }) |
| 26 | th.AssertNoErr(t, err) |
| 27 | th.CheckEquals(t, 1, count) |
| 28 | } |