blob: 23727c468aa2f23b87e48d123b29ee0c3efbcbb7 [file] [log] [blame]
Jamie Hannaford4c2a1f22014-10-23 17:31:55 +02001// +build acceptance
2
Jamie Hannafordaf209d12014-10-22 12:37:48 +02003package v1
4
5import (
Jamie Hannaford9b77ef92014-10-23 16:56:59 +02006 "os"
Jamie Hannafordaf209d12014-10-22 12:37:48 +02007 "testing"
8
Jon Perritt27249f42016-02-18 10:35:59 -06009 "github.com/gophercloud/gophercloud"
10 "github.com/gophercloud/gophercloud/acceptance/tools"
11 "github.com/gophercloud/gophercloud/rackspace"
12 th "github.com/gophercloud/gophercloud/testhelper"
Jamie Hannafordaf209d12014-10-22 12:37:48 +020013)
14
15func newClient() (*gophercloud.ServiceClient, error) {
Jamie Hannaford29149be2014-10-23 14:49:44 +020016 opts, err := rackspace.AuthOptionsFromEnv()
Jamie Hannafordaf209d12014-10-22 12:37:48 +020017 if err != nil {
18 return nil, err
19 }
Jamie Hannaford9b77ef92014-10-23 16:56:59 +020020 opts = tools.OnlyRS(opts)
21 region := os.Getenv("RS_REGION")
Jamie Hannafordaf209d12014-10-22 12:37:48 +020022
23 provider, err := rackspace.AuthenticatedClient(opts)
24 if err != nil {
25 return nil, err
26 }
27
28 return rackspace.NewBlockStorageV1(provider, gophercloud.EndpointOpts{
Jamie Hannaford9b77ef92014-10-23 16:56:59 +020029 Region: region,
Jamie Hannafordaf209d12014-10-22 12:37:48 +020030 })
31}
32
33func setup(t *testing.T) *gophercloud.ServiceClient {
34 client, err := newClient()
35 th.AssertNoErr(t, err)
36
37 return client
38}