blob: 921fc92fb2a748f72a885a26db72b9828e9d5ea3 [file] [log] [blame]
Jamie Hannafordbef53932014-11-05 12:39:30 +01001// +build acceptance lbs
2
3package v1
4
5import (
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
15func 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
25func 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
36func 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
47func setup(t *testing.T) *gophercloud.ServiceClient {
48 client, err := newClient()
49 th.AssertNoErr(t, err)
50
51 return client
52}