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