Ash Wilson | f4d6363 | 2014-10-09 14:54:06 -0400 | [diff] [blame] | 1 | // +build acceptance |
| 2 | |
| 3 | package v2 |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | |
| 8 | "github.com/rackspace/gophercloud/pagination" |
| 9 | extensions2 "github.com/rackspace/gophercloud/rackspace/identity/v2/extensions" |
| 10 | th "github.com/rackspace/gophercloud/testhelper" |
| 11 | ) |
| 12 | |
| 13 | func TestExtensions(t *testing.T) { |
| 14 | service := authenticatedClient(t) |
| 15 | |
| 16 | t.Logf("Extensions available on this identity endpoint:") |
| 17 | count := 0 |
| 18 | var chosen string |
| 19 | err := extensions2.List(service).EachPage(func(page pagination.Page) (bool, error) { |
| 20 | t.Logf("--- Page %02d ---", count) |
| 21 | |
| 22 | extensions, err := extensions2.ExtractExtensions(page) |
| 23 | th.AssertNoErr(t, err) |
| 24 | |
| 25 | for i, ext := range extensions { |
| 26 | if chosen == "" { |
| 27 | chosen = ext.Alias |
| 28 | } |
| 29 | |
| 30 | t.Logf("[%02d] name=[%s] namespace=[%s]", i, ext.Name, ext.Namespace) |
| 31 | t.Logf(" alias=[%s] updated=[%s]", ext.Alias, ext.Updated) |
| 32 | t.Logf(" description=[%s]", ext.Description) |
| 33 | } |
| 34 | |
| 35 | count++ |
| 36 | return true, nil |
| 37 | }) |
| 38 | th.AssertNoErr(t, err) |
| 39 | |
| 40 | if chosen == "" { |
| 41 | t.Logf("No extensions found.") |
| 42 | return |
| 43 | } |
| 44 | |
| 45 | ext, err := extensions2.Get(service, chosen).Extract() |
| 46 | th.AssertNoErr(t, err) |
| 47 | |
| 48 | t.Logf("Detail for extension [%s]:", chosen) |
| 49 | t.Logf(" name=[%s]", ext.Name) |
| 50 | t.Logf(" namespace=[%s]", ext.Namespace) |
| 51 | t.Logf(" alias=[%s]", ext.Alias) |
| 52 | t.Logf(" updated=[%s]", ext.Updated) |
| 53 | t.Logf(" description=[%s]", ext.Description) |
| 54 | } |