Ash Wilson | fd794d5 | 2014-09-03 14:30:43 -0400 | [diff] [blame] | 1 | // +build acceptance |
| 2 | |
| 3 | package v3 |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | |
Ash Wilson | dd7188d | 2014-09-05 14:02:42 -0400 | [diff] [blame^] | 8 | "github.com/rackspace/gophercloud" |
Ash Wilson | fd794d5 | 2014-09-03 14:30:43 -0400 | [diff] [blame] | 9 | services3 "github.com/rackspace/gophercloud/openstack/identity/v3/services" |
Ash Wilson | fd794d5 | 2014-09-03 14:30:43 -0400 | [diff] [blame] | 10 | ) |
| 11 | |
| 12 | func TestListServices(t *testing.T) { |
Ash Wilson | fd794d5 | 2014-09-03 14:30:43 -0400 | [diff] [blame] | 13 | // Create a service client. |
Ash Wilson | dd7188d | 2014-09-05 14:02:42 -0400 | [diff] [blame^] | 14 | serviceClient := createAuthenticatedClient(t) |
Ash Wilson | fd794d5 | 2014-09-03 14:30:43 -0400 | [diff] [blame] | 15 | |
| 16 | // Use the service to create a token. |
| 17 | results, err := services3.List(serviceClient, services3.ListOpts{}) |
| 18 | if err != nil { |
| 19 | t.Fatalf("Unable to get token: %v", err) |
| 20 | } |
| 21 | |
Ash Wilson | dd7188d | 2014-09-05 14:02:42 -0400 | [diff] [blame^] | 22 | err = gophercloud.EachPage(results, func(page gophercloud.Collection) bool { |
| 23 | t.Logf("--- Page ---") |
| 24 | for _, service := range services3.AsServices(page) { |
| 25 | t.Logf("Service: %32s %15s %10s %s", service.ID, service.Type, service.Name, *service.Description) |
| 26 | } |
| 27 | return true |
| 28 | }) |
| 29 | if err != nil { |
| 30 | t.Errorf("Unexpected error traversing pages: %v", err) |
Ash Wilson | fd794d5 | 2014-09-03 14:30:43 -0400 | [diff] [blame] | 31 | } |
| 32 | } |