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 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 8 | "github.com/gophercloud/gophercloud/acceptance/clients" |
| 9 | "github.com/gophercloud/gophercloud/openstack/identity/v2/tenants" |
Ash Wilson | f4aee1e | 2014-10-03 15:25:13 -0400 | [diff] [blame] | 10 | ) |
| 11 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 12 | func TestTenantsList(t *testing.T) { |
| 13 | client, err := clients.NewIdentityV2Client() |
| 14 | if err != nil { |
| 15 | t.Fatalf("Unable to obtain an identity client: %v") |
| 16 | } |
Ash Wilson | f4aee1e | 2014-10-03 15:25:13 -0400 | [diff] [blame] | 17 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 18 | allPages, err := tenants.List(client, nil).AllPages() |
| 19 | if err != nil { |
| 20 | t.Fatalf("Unable to list tenants: %v", err) |
| 21 | } |
Ash Wilson | f4aee1e | 2014-10-03 15:25:13 -0400 | [diff] [blame] | 22 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 23 | allTenants, err := tenants.ExtractTenants(allPages) |
| 24 | if err != nil { |
| 25 | t.Fatalf("Unable to extract tenants: %v", err) |
| 26 | } |
Ash Wilson | f4aee1e | 2014-10-03 15:25:13 -0400 | [diff] [blame] | 27 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 28 | for _, tenant := range allTenants { |
| 29 | PrintTenant(t, &tenant) |
| 30 | } |
Ash Wilson | f4aee1e | 2014-10-03 15:25:13 -0400 | [diff] [blame] | 31 | } |