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" |
Jamie Hannaford | c9da4b4 | 2014-11-05 16:34:56 +0100 | [diff] [blame] | 7 | "strconv" |
| 8 | "strings" |
Jamie Hannaford | bef5393 | 2014-11-05 12:39:30 +0100 | [diff] [blame] | 9 | "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 | |
| 17 | func 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 | |
| 27 | func 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 | |
| 38 | func 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 | |
| 49 | func setup(t *testing.T) *gophercloud.ServiceClient { |
| 50 | client, err := newClient() |
| 51 | th.AssertNoErr(t, err) |
| 52 | |
| 53 | return client |
| 54 | } |
Jamie Hannaford | c9da4b4 | 2014-11-05 16:34:56 +0100 | [diff] [blame] | 55 | |
| 56 | func 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 | } |