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