blob: 6081a498e34e844caa2d24f3c9a922218f64fcd4 [file] [log] [blame]
Ash Wilson72f702b2014-10-10 14:07:37 -04001// +build acceptance
2
3package v2
4
5import (
6 "testing"
7
8 "github.com/rackspace/gophercloud/pagination"
9 rstenants "github.com/rackspace/gophercloud/rackspace/identity/v2/tenants"
10 th "github.com/rackspace/gophercloud/testhelper"
11)
12
13func TestTenants(t *testing.T) {
14 service := authenticatedClient(t)
15
16 t.Logf("Tenants available to the currently issued token:")
17 count := 0
18 err := rstenants.List(service, nil).EachPage(func(page pagination.Page) (bool, error) {
19 t.Logf("--- Page %02d ---", count)
20
21 tenants, err := rstenants.ExtractTenants(page)
22 th.AssertNoErr(t, err)
23
24 for i, tenant := range tenants {
25 t.Logf("[%02d] id=[%s]", i, tenant.ID)
26 t.Logf(" name=[%s] enabled=[%v]", i, tenant.Name, tenant.Enabled)
27 t.Logf(" description=[%s]", tenant.Description)
28 }
29
30 count++
31 return true, nil
32 })
33 th.AssertNoErr(t, err)
34 if count == 0 {
35 t.Errorf("No tenants listed for your current token.")
36 }
37}