Jon Perritt | 53c8a3a | 2014-11-24 07:46:35 -0700 | [diff] [blame] | 1 | package v2 |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/rackspace/gophercloud" |
| 8 | "github.com/rackspace/gophercloud/rackspace" |
| 9 | th "github.com/rackspace/gophercloud/testhelper" |
| 10 | ) |
| 11 | |
| 12 | var Client *gophercloud.ServiceClient |
| 13 | |
| 14 | func NewClient() (*gophercloud.ServiceClient, error) { |
| 15 | opts, err := rackspace.AuthOptionsFromEnv() |
| 16 | if err != nil { |
| 17 | return nil, err |
| 18 | } |
| 19 | |
| 20 | provider, err := rackspace.AuthenticatedClient(opts) |
| 21 | if err != nil { |
| 22 | return nil, err |
| 23 | } |
| 24 | |
| 25 | return rackspace.NewNetworkV2(provider, gophercloud.EndpointOpts{ |
| 26 | Name: "cloudNetworks", |
| 27 | Region: os.Getenv("RS_REGION"), |
| 28 | }) |
| 29 | } |
| 30 | |
| 31 | func Setup(t *testing.T) { |
| 32 | client, err := NewClient() |
| 33 | th.AssertNoErr(t, err) |
| 34 | Client = client |
| 35 | } |
| 36 | |
| 37 | func Teardown() { |
| 38 | Client = nil |
| 39 | } |