blob: 6dd58af1b5f2b85baae02fd5c6e3b524c6460e8e [file] [log] [blame]
Jamie Hannaford5e45ccb2014-09-22 15:41:10 +02001package v2
2
3import (
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
13var Client *gophercloud.ServiceClient
14
15func 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
32func Setup(t *testing.T) {
33 client, err := NewClient()
34 th.AssertNoErr(t, err)
35 Client = client
36}
37
38func Teardown() {
39 Client = nil
40}