blob: 4ce05e69ca846660b20764d085405d06cc28731a [file] [log] [blame]
Jamie Hannafordbef53932014-11-05 12:39:30 +01001// +build acceptance lbs
2
3package v1
4
5import (
6 "os"
Jamie Hannafordc9da4b42014-11-05 16:34:56 +01007 "strconv"
8 "strings"
Jamie Hannafordbef53932014-11-05 12:39:30 +01009 "testing"
10
11 "github.com/rackspace/gophercloud"
12 "github.com/rackspace/gophercloud/acceptance/tools"
13 "github.com/rackspace/gophercloud/rackspace"
14 th "github.com/rackspace/gophercloud/testhelper"
15)
16
17func newProvider() (*gophercloud.ProviderClient, error) {
18 opts, err := rackspace.AuthOptionsFromEnv()
19 if err != nil {
20 return nil, err
21 }
22 opts = tools.OnlyRS(opts)
23
24 return rackspace.AuthenticatedClient(opts)
25}
26
27func newClient() (*gophercloud.ServiceClient, error) {
28 provider, err := newProvider()
29 if err != nil {
30 return nil, err
31 }
32
33 return rackspace.NewLBV1(provider, gophercloud.EndpointOpts{
34 Region: os.Getenv("RS_REGION"),
35 })
36}
37
38func newComputeClient() (*gophercloud.ServiceClient, error) {
39 provider, err := newProvider()
40 if err != nil {
41 return nil, err
42 }
43
44 return rackspace.NewComputeV2(provider, gophercloud.EndpointOpts{
45 Region: os.Getenv("RS_REGION"),
46 })
47}
48
49func setup(t *testing.T) *gophercloud.ServiceClient {
50 client, err := newClient()
51 th.AssertNoErr(t, err)
52
53 return client
54}
Jamie Hannafordc9da4b42014-11-05 16:34:56 +010055
56func intsToStr(ids []int) string {
57 strIDs := []string{}
58 for _, id := range ids {
59 strIDs = append(strIDs, strconv.Itoa(id))
60 }
61 return strings.Join(strIDs, ", ")
62}