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