move unit tests into 'testing' directories
diff --git a/openstack/db/v1/instances/testing/doc.go b/openstack/db/v1/instances/testing/doc.go
new file mode 100644
index 0000000..7603f83
--- /dev/null
+++ b/openstack/db/v1/instances/testing/doc.go
@@ -0,0 +1 @@
+package testing
diff --git a/openstack/db/v1/instances/fixtures.go b/openstack/db/v1/instances/testing/fixtures.go
similarity index 89%
rename from openstack/db/v1/instances/fixtures.go
rename to openstack/db/v1/instances/testing/fixtures.go
index 6be384c..e0a0d28 100644
--- a/openstack/db/v1/instances/fixtures.go
+++ b/openstack/db/v1/instances/testing/fixtures.go
@@ -1,6 +1,4 @@
-// +build fixtures
-
-package instances
+package testing
import (
"fmt"
@@ -10,6 +8,7 @@
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/db/v1/datastores"
"github.com/gophercloud/gophercloud/openstack/db/v1/flavors"
+ "github.com/gophercloud/gophercloud/openstack/db/v1/instances"
"github.com/gophercloud/gophercloud/testhelper/fixture"
)
@@ -110,24 +109,24 @@
isUserEnabledResp = `{"rootEnabled":true}`
)
-var expectedInstance = Instance{
+var expectedInstance = instances.Instance{
Created: timeVal,
Updated: timeVal,
Flavor: flavors.Flavor{
ID: 1,
Links: []gophercloud.Link{
- gophercloud.Link{Href: "https://my-openstack.com/v1.0/1234/flavors/1", Rel: "self"},
- gophercloud.Link{Href: "https://my-openstack.com/v1.0/1234/flavors/1", Rel: "bookmark"},
+ {Href: "https://my-openstack.com/v1.0/1234/flavors/1", Rel: "self"},
+ {Href: "https://my-openstack.com/v1.0/1234/flavors/1", Rel: "bookmark"},
},
},
Hostname: "e09ad9a3f73309469cf1f43d11e79549caf9acf2.my-openstack.com",
ID: instanceID,
Links: []gophercloud.Link{
- gophercloud.Link{Href: "https://my-openstack.com/v1.0/1234/instances/1", Rel: "self"},
+ {Href: "https://my-openstack.com/v1.0/1234/instances/1", Rel: "self"},
},
Name: "json_rack_instance",
Status: "BUILD",
- Volume: Volume{Size: 2},
+ Volume: instances.Volume{Size: 2},
Datastore: datastores.DatastorePartial{
Type: "mysql",
Version: "5.6",
diff --git a/openstack/db/v1/instances/requests_test.go b/openstack/db/v1/instances/testing/requests_test.go
similarity index 67%
rename from openstack/db/v1/instances/requests_test.go
rename to openstack/db/v1/instances/testing/requests_test.go
index 3caac23..e3c81e3 100644
--- a/openstack/db/v1/instances/requests_test.go
+++ b/openstack/db/v1/instances/testing/requests_test.go
@@ -1,9 +1,10 @@
-package instances
+package testing
import (
"testing"
db "github.com/gophercloud/gophercloud/openstack/db/v1/databases"
+ "github.com/gophercloud/gophercloud/openstack/db/v1/instances"
"github.com/gophercloud/gophercloud/openstack/db/v1/users"
"github.com/gophercloud/gophercloud/pagination"
th "github.com/gophercloud/gophercloud/testhelper"
@@ -15,26 +16,26 @@
defer th.TeardownHTTP()
HandleCreate(t)
- opts := CreateOpts{
+ opts := instances.CreateOpts{
Name: "json_rack_instance",
FlavorRef: "1",
Databases: db.BatchCreateOpts{
- db.CreateOpts{CharSet: "utf8", Collate: "utf8_general_ci", Name: "sampledb"},
- db.CreateOpts{Name: "nextround"},
+ {CharSet: "utf8", Collate: "utf8_general_ci", Name: "sampledb"},
+ {Name: "nextround"},
},
Users: users.BatchCreateOpts{
- users.CreateOpts{
+ {
Name: "demouser",
Password: "demopassword",
Databases: db.BatchCreateOpts{
- db.CreateOpts{Name: "sampledb"},
+ {Name: "sampledb"},
},
},
},
Size: 2,
}
- instance, err := Create(fake.ServiceClient(), opts).Extract()
+ instance, err := instances.Create(fake.ServiceClient(), opts).Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, &expectedInstance, instance)
@@ -46,15 +47,15 @@
HandleList(t)
pages := 0
- err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
+ err := instances.List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
pages++
- actual, err := ExtractInstances(page)
+ actual, err := instances.ExtractInstances(page)
if err != nil {
return false, err
}
- th.CheckDeepEquals(t, []Instance{expectedInstance}, actual)
+ th.CheckDeepEquals(t, []instances.Instance{expectedInstance}, actual)
return true, nil
})
@@ -67,7 +68,7 @@
defer th.TeardownHTTP()
HandleGet(t)
- instance, err := Get(fake.ServiceClient(), instanceID).Extract()
+ instance, err := instances.Get(fake.ServiceClient(), instanceID).Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, &expectedInstance, instance)
@@ -78,7 +79,7 @@
defer th.TeardownHTTP()
HandleDelete(t)
- res := Delete(fake.ServiceClient(), instanceID)
+ res := instances.Delete(fake.ServiceClient(), instanceID)
th.AssertNoErr(t, res.Err)
}
@@ -88,7 +89,7 @@
HandleEnableRoot(t)
expected := &users.User{Name: "root", Password: "secretsecret"}
- user, err := EnableRootUser(fake.ServiceClient(), instanceID).Extract()
+ user, err := instances.EnableRootUser(fake.ServiceClient(), instanceID).Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, expected, user)
@@ -99,7 +100,7 @@
defer th.TeardownHTTP()
HandleIsRootEnabled(t)
- isEnabled, err := IsRootEnabled(fake.ServiceClient(), instanceID).Extract()
+ isEnabled, err := instances.IsRootEnabled(fake.ServiceClient(), instanceID).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, true, isEnabled)
@@ -110,7 +111,7 @@
defer th.TeardownHTTP()
HandleRestart(t)
- res := Restart(fake.ServiceClient(), instanceID)
+ res := instances.Restart(fake.ServiceClient(), instanceID)
th.AssertNoErr(t, res.Err)
}
@@ -119,7 +120,7 @@
defer th.TeardownHTTP()
HandleResize(t)
- res := Resize(fake.ServiceClient(), instanceID, "2")
+ res := instances.Resize(fake.ServiceClient(), instanceID, "2")
th.AssertNoErr(t, res.Err)
}
@@ -128,6 +129,6 @@
defer th.TeardownHTTP()
HandleResizeVol(t)
- res := ResizeVolume(fake.ServiceClient(), instanceID, 4)
+ res := instances.ResizeVolume(fake.ServiceClient(), instanceID, 4)
th.AssertNoErr(t, res.Err)
}