blob: ed457d4cfa472a8e9f179a5e82c4de14d14633bf [file] [log] [blame]
Jamie Hannafordc21ffb92014-10-30 11:46:31 +01001// +build acceptance identity
Ash Wilsonf4aee1e2014-10-03 15:25:13 -04002
3package v2
4
5import (
6 "testing"
7
Joe Topjian918f5732016-08-15 08:47:08 -06008 "github.com/gophercloud/gophercloud/acceptance/clients"
9 "github.com/gophercloud/gophercloud/openstack/identity/v2/tenants"
Ash Wilsonf4aee1e2014-10-03 15:25:13 -040010)
11
Joe Topjian918f5732016-08-15 08:47:08 -060012func 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 Wilsonf4aee1e2014-10-03 15:25:13 -040017
Joe Topjian918f5732016-08-15 08:47:08 -060018 allPages, err := tenants.List(client, nil).AllPages()
19 if err != nil {
20 t.Fatalf("Unable to list tenants: %v", err)
21 }
Ash Wilsonf4aee1e2014-10-03 15:25:13 -040022
Joe Topjian918f5732016-08-15 08:47:08 -060023 allTenants, err := tenants.ExtractTenants(allPages)
24 if err != nil {
25 t.Fatalf("Unable to extract tenants: %v", err)
26 }
Ash Wilsonf4aee1e2014-10-03 15:25:13 -040027
Joe Topjian918f5732016-08-15 08:47:08 -060028 for _, tenant := range allTenants {
29 PrintTenant(t, &tenant)
30 }
Ash Wilsonf4aee1e2014-10-03 15:25:13 -040031}