blob: e9fdd9920596649806c9e854aa9c3818ddb6eb10 [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
9 "github.com/rackspace/gophercloud"
Jamie Hannaford9b77ef92014-10-23 16:56:59 +020010 "github.com/rackspace/gophercloud/acceptance/tools"
Jamie Hannafordaf209d12014-10-22 12:37:48 +020011 "github.com/rackspace/gophercloud/rackspace"
12 th "github.com/rackspace/gophercloud/testhelper"
13)
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}