Jamie Hannaford | bef5393 | 2014-11-05 12:39:30 +0100 | [diff] [blame^] | 1 | // +build acceptance lbs |
| 2 | |
| 3 | package v1 |
| 4 | |
| 5 | import ( |
| 6 | "os" |
| 7 | "testing" |
| 8 | |
| 9 | "github.com/rackspace/gophercloud" |
| 10 | "github.com/rackspace/gophercloud/acceptance/tools" |
| 11 | "github.com/rackspace/gophercloud/rackspace" |
| 12 | th "github.com/rackspace/gophercloud/testhelper" |
| 13 | ) |
| 14 | |
| 15 | func newProvider() (*gophercloud.ProviderClient, error) { |
| 16 | opts, err := rackspace.AuthOptionsFromEnv() |
| 17 | if err != nil { |
| 18 | return nil, err |
| 19 | } |
| 20 | opts = tools.OnlyRS(opts) |
| 21 | |
| 22 | return rackspace.AuthenticatedClient(opts) |
| 23 | } |
| 24 | |
| 25 | func newClient() (*gophercloud.ServiceClient, error) { |
| 26 | provider, err := newProvider() |
| 27 | if err != nil { |
| 28 | return nil, err |
| 29 | } |
| 30 | |
| 31 | return rackspace.NewLBV1(provider, gophercloud.EndpointOpts{ |
| 32 | Region: os.Getenv("RS_REGION"), |
| 33 | }) |
| 34 | } |
| 35 | |
| 36 | func newComputeClient() (*gophercloud.ServiceClient, error) { |
| 37 | provider, err := newProvider() |
| 38 | if err != nil { |
| 39 | return nil, err |
| 40 | } |
| 41 | |
| 42 | return rackspace.NewComputeV2(provider, gophercloud.EndpointOpts{ |
| 43 | Region: os.Getenv("RS_REGION"), |
| 44 | }) |
| 45 | } |
| 46 | |
| 47 | func setup(t *testing.T) *gophercloud.ServiceClient { |
| 48 | client, err := newClient() |
| 49 | th.AssertNoErr(t, err) |
| 50 | |
| 51 | return client |
| 52 | } |