blob: 00375e279deb582e3e2aa6a8d0ecb8272abd0758 [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 Wilson7083d022014-09-09 14:10:43 -040015 if serviceClient == nil {
16 return
17 }
Ash Wilsonfd794d52014-09-03 14:30:43 -040018
Ash Wilson2c0e45b2014-09-09 14:52:42 -040019 // Use the client to list all available services.
Ash Wilsonfd794d52014-09-03 14:30:43 -040020 results, err := services3.List(serviceClient, services3.ListOpts{})
21 if err != nil {
Ash Wilson2c0e45b2014-09-09 14:52:42 -040022 t.Fatalf("Unable to list services: %v", err)
Ash Wilsonfd794d52014-09-03 14:30:43 -040023 }
24
Ash Wilsondd7188d2014-09-05 14:02:42 -040025 err = gophercloud.EachPage(results, func(page gophercloud.Collection) bool {
26 t.Logf("--- Page ---")
27 for _, service := range services3.AsServices(page) {
28 t.Logf("Service: %32s %15s %10s %s", service.ID, service.Type, service.Name, *service.Description)
29 }
30 return true
31 })
32 if err != nil {
33 t.Errorf("Unexpected error traversing pages: %v", err)
Ash Wilsonfd794d52014-09-03 14:30:43 -040034 }
35}