Jamie Hannaford | 4c2a1f2 | 2014-10-23 17:31:55 +0200 | [diff] [blame] | 1 | // +build acceptance |
| 2 | |
Jamie Hannaford | af209d1 | 2014-10-22 12:37:48 +0200 | [diff] [blame] | 3 | package v1 |
| 4 | |
| 5 | import ( |
Jamie Hannaford | 9b77ef9 | 2014-10-23 16:56:59 +0200 | [diff] [blame] | 6 | "os" |
Jamie Hannaford | af209d1 | 2014-10-22 12:37:48 +0200 | [diff] [blame] | 7 | "testing" |
| 8 | |
| 9 | "github.com/rackspace/gophercloud" |
Jamie Hannaford | 9b77ef9 | 2014-10-23 16:56:59 +0200 | [diff] [blame] | 10 | "github.com/rackspace/gophercloud/acceptance/tools" |
Jamie Hannaford | af209d1 | 2014-10-22 12:37:48 +0200 | [diff] [blame] | 11 | "github.com/rackspace/gophercloud/rackspace" |
| 12 | th "github.com/rackspace/gophercloud/testhelper" |
| 13 | ) |
| 14 | |
| 15 | func newClient() (*gophercloud.ServiceClient, error) { |
Jamie Hannaford | 29149be | 2014-10-23 14:49:44 +0200 | [diff] [blame] | 16 | opts, err := rackspace.AuthOptionsFromEnv() |
Jamie Hannaford | af209d1 | 2014-10-22 12:37:48 +0200 | [diff] [blame] | 17 | if err != nil { |
| 18 | return nil, err |
| 19 | } |
Jamie Hannaford | 9b77ef9 | 2014-10-23 16:56:59 +0200 | [diff] [blame] | 20 | opts = tools.OnlyRS(opts) |
| 21 | region := os.Getenv("RS_REGION") |
Jamie Hannaford | af209d1 | 2014-10-22 12:37:48 +0200 | [diff] [blame] | 22 | |
| 23 | provider, err := rackspace.AuthenticatedClient(opts) |
| 24 | if err != nil { |
| 25 | return nil, err |
| 26 | } |
| 27 | |
| 28 | return rackspace.NewBlockStorageV1(provider, gophercloud.EndpointOpts{ |
Jamie Hannaford | 9b77ef9 | 2014-10-23 16:56:59 +0200 | [diff] [blame] | 29 | Region: region, |
Jamie Hannaford | af209d1 | 2014-10-22 12:37:48 +0200 | [diff] [blame] | 30 | }) |
| 31 | } |
| 32 | |
| 33 | func setup(t *testing.T) *gophercloud.ServiceClient { |
| 34 | client, err := newClient() |
| 35 | th.AssertNoErr(t, err) |
| 36 | |
| 37 | return client |
| 38 | } |