blob: 2054598295a7447e81a2fa7de16f9b254e8971ea [file] [log] [blame]
Ash Wilsonf4aee1e2014-10-03 15:25:13 -04001// +build acceptance
2
3package v2
4
5import (
6 "testing"
7
8 tenants2 "github.com/rackspace/gophercloud/openstack/identity/v2/tenants"
9 "github.com/rackspace/gophercloud/pagination"
10 th "github.com/rackspace/gophercloud/testhelper"
11)
12
13func 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 Wilson7c8b1382014-10-03 15:50:56 -040019 t.Logf("--- Page %02d ---", count)
Ash Wilsonf4aee1e2014-10-03 15:25:13 -040020
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}