Jamie Hannaford | c21ffb9 | 2014-10-30 11:46:31 +0100 | [diff] [blame] | 1 | // +build acceptance identity |
Ash Wilson | f4aee1e | 2014-10-03 15:25:13 -0400 | [diff] [blame] | 2 | |
| 3 | package v2 |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame^] | 8 | tenants2 "github.com/gophercloud/gophercloud/openstack/identity/v2/tenants" |
| 9 | "github.com/gophercloud/gophercloud/pagination" |
| 10 | th "github.com/gophercloud/gophercloud/testhelper" |
Ash Wilson | f4aee1e | 2014-10-03 15:25:13 -0400 | [diff] [blame] | 11 | ) |
| 12 | |
| 13 | func TestEnumerateTenants(t *testing.T) { |
| 14 | service := authenticatedClient(t) |
| 15 | |
| 16 | t.Logf("Tenants to which your current token grants access:") |
| 17 | count := 0 |
| 18 | err := tenants2.List(service, nil).EachPage(func(page pagination.Page) (bool, error) { |
Ash Wilson | 7c8b138 | 2014-10-03 15:50:56 -0400 | [diff] [blame] | 19 | t.Logf("--- Page %02d ---", count) |
Ash Wilson | f4aee1e | 2014-10-03 15:25:13 -0400 | [diff] [blame] | 20 | |
| 21 | tenants, err := tenants2.ExtractTenants(page) |
| 22 | th.AssertNoErr(t, err) |
| 23 | for i, tenant := range tenants { |
| 24 | t.Logf("[%02d] name=[%s] id=[%s] description=[%s] enabled=[%v]", |
| 25 | i, tenant.Name, tenant.ID, tenant.Description, tenant.Enabled) |
| 26 | } |
| 27 | |
| 28 | count++ |
| 29 | return true, nil |
| 30 | }) |
| 31 | th.AssertNoErr(t, err) |
| 32 | } |