Jamie Hannaford | 5e45ccb | 2014-09-22 15:41:10 +0200 | [diff] [blame] | 1 | package v2 |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/rackspace/gophercloud" |
| 8 | "github.com/rackspace/gophercloud/openstack" |
| 9 | "github.com/rackspace/gophercloud/openstack/utils" |
| 10 | th "github.com/rackspace/gophercloud/testhelper" |
| 11 | ) |
| 12 | |
| 13 | var Client *gophercloud.ServiceClient |
| 14 | |
| 15 | func NewClient() (*gophercloud.ServiceClient, error) { |
| 16 | opts, err := utils.AuthOptions() |
| 17 | if err != nil { |
| 18 | return nil, err |
| 19 | } |
| 20 | |
| 21 | provider, err := openstack.AuthenticatedClient(opts) |
| 22 | if err != nil { |
| 23 | return nil, err |
| 24 | } |
| 25 | |
| 26 | return openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{ |
| 27 | Name: "neutron", |
| 28 | Region: os.Getenv("OS_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 | } |