Fixes to client setup and build tags
diff --git a/acceptance/openstack/networking/v2/network_test.go b/acceptance/openstack/networking/v2/network_test.go
index 9ec833d..312c234 100644
--- a/acceptance/openstack/networking/v2/network_test.go
+++ b/acceptance/openstack/networking/v2/network_test.go
@@ -1,7 +1,8 @@
+// +build acceptance networking
+
package v2
import (
- "fmt"
"os"
"testing"
@@ -24,24 +25,16 @@
return nil, err
}
- eo := gophercloud.EndpointOpts{
- Type: "network",
+ return openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{
Name: "neutron",
Region: os.Getenv("OS_REGION_NAME"),
- }
- url, err := provider.EndpointLocator(eo)
- if err != nil {
- return nil, err
- }
-
- return &gophercloud.ServiceClient{Provider: provider, Endpoint: url}, nil
+ })
}
-func Setup() {
+func Setup(t *testing.T) {
client, err := NewClient()
if err != nil {
- fmt.Println("Client failed to load")
- return
+ t.Fatalf("Error creating client: %s", err)
}
Client = client
@@ -52,7 +45,7 @@
}
func TestListAPIVersions(t *testing.T) {
- Setup()
+ Setup(t)
defer Teardown()
res, err := networks.APIVersions(Client)
diff --git a/openstack/client.go b/openstack/client.go
index 4fcf057..a73f301 100644
--- a/openstack/client.go
+++ b/openstack/client.go
@@ -293,3 +293,12 @@
}
return &gophercloud.ServiceClient{Provider: client, Endpoint: url}, nil
}
+
+func NewNetworkV2(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
+ eo.ApplyDefaults("network")
+ url, err := client.EndpointLocator(eo)
+ if err != nil {
+ return nil, err
+ }
+ return &gophercloud.ServiceClient{Provider: client, Endpoint: url}, nil
+}