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