blob: 0dd49d0c46aff24fbf6518341351cc6194695c34 [file] [log] [blame]
Ash Wilsonfd794d52014-09-03 14:30:43 -04001// +build acceptance
2
3package v3
4
5import (
6 "testing"
7
Ash Wilsondd7188d2014-09-05 14:02:42 -04008 "github.com/rackspace/gophercloud"
Ash Wilsonfd794d52014-09-03 14:30:43 -04009 services3 "github.com/rackspace/gophercloud/openstack/identity/v3/services"
Ash Wilsonfd794d52014-09-03 14:30:43 -040010)
11
12func TestListServices(t *testing.T) {
Ash Wilsonfd794d52014-09-03 14:30:43 -040013 // Create a service client.
Ash Wilsondd7188d2014-09-05 14:02:42 -040014 serviceClient := createAuthenticatedClient(t)
Ash Wilsonfd794d52014-09-03 14:30:43 -040015
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 Wilsondd7188d2014-09-05 14:02:42 -040022 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 Wilsonfd794d52014-09-03 14:30:43 -040031 }
32}