move unit tests into 'testing' directories
diff --git a/openstack/identity/v2/tokens/testing/doc.go b/openstack/identity/v2/tokens/testing/doc.go
new file mode 100644
index 0000000..7603f83
--- /dev/null
+++ b/openstack/identity/v2/tokens/testing/doc.go
@@ -0,0 +1 @@
+package testing
diff --git a/openstack/identity/v2/tokens/fixtures.go b/openstack/identity/v2/tokens/testing/fixtures.go
similarity index 86%
rename from openstack/identity/v2/tokens/fixtures.go
rename to openstack/identity/v2/tokens/testing/fixtures.go
index 85a9571..d3a8f24 100644
--- a/openstack/identity/v2/tokens/fixtures.go
+++ b/openstack/identity/v2/tokens/testing/fixtures.go
@@ -1,6 +1,4 @@
-// +build fixtures
-
-package tokens
+package testing
import (
"fmt"
@@ -9,12 +7,13 @@
"time"
"github.com/gophercloud/gophercloud/openstack/identity/v2/tenants"
+ "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens"
th "github.com/gophercloud/gophercloud/testhelper"
thclient "github.com/gophercloud/gophercloud/testhelper/client"
)
// ExpectedToken is the token that should be parsed from TokenCreationResponse.
-var ExpectedToken = &Token{
+var ExpectedToken = &tokens.Token{
ID: "aaaabbbbccccdddd",
ExpiresAt: time.Date(2014, time.January, 31, 15, 30, 58, 0, time.UTC),
Tenant: tenants.Tenant{
@@ -26,27 +25,27 @@
}
// ExpectedServiceCatalog is the service catalog that should be parsed from TokenCreationResponse.
-var ExpectedServiceCatalog = &ServiceCatalog{
- Entries: []CatalogEntry{
- CatalogEntry{
+var ExpectedServiceCatalog = &tokens.ServiceCatalog{
+ Entries: []tokens.CatalogEntry{
+ {
Name: "inscrutablewalrus",
Type: "something",
- Endpoints: []Endpoint{
- Endpoint{
+ Endpoints: []tokens.Endpoint{
+ {
PublicURL: "http://something0:1234/v2/",
Region: "region0",
},
- Endpoint{
+ {
PublicURL: "http://something1:1234/v2/",
Region: "region1",
},
},
},
- CatalogEntry{
+ {
Name: "arbitrarypenguin",
Type: "else",
- Endpoints: []Endpoint{
- Endpoint{
+ Endpoints: []tokens.Endpoint{
+ {
PublicURL: "http://else0:4321/v3/",
Region: "region0",
},
@@ -56,10 +55,10 @@
}
// ExpectedUser is the token that should be parsed from TokenGetResponse.
-var ExpectedUser = &User{
+var ExpectedUser = &tokens.User{
ID: "a530fefc3d594c4ba2693a4ecd6be74e",
Name: "apiserver",
- Roles: []Role{{"member"}, {"service"}},
+ Roles: []tokens.Role{{"member"}, {"service"}},
UserName: "apiserver",
}
@@ -123,19 +122,19 @@
"name": "test"
}
},
- "serviceCatalog": [],
+ "serviceCatalog": [],
"user": {
- "id": "a530fefc3d594c4ba2693a4ecd6be74e",
- "name": "apiserver",
+ "id": "a530fefc3d594c4ba2693a4ecd6be74e",
+ "name": "apiserver",
"roles": [
{
"name": "member"
- },
+ },
{
"name": "service"
}
- ],
- "roles_links": [],
+ ],
+ "roles_links": [],
"username": "apiserver"
}
}
@@ -172,7 +171,7 @@
// IsSuccessful ensures that a CreateResult was successful and contains the correct token and
// service catalog.
-func IsSuccessful(t *testing.T, result CreateResult) {
+func IsSuccessful(t *testing.T, result tokens.CreateResult) {
token, err := result.ExtractToken()
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, ExpectedToken, token)
@@ -184,7 +183,7 @@
// GetIsSuccessful ensures that a GetResult was successful and contains the correct token and
// User Info.
-func GetIsSuccessful(t *testing.T, result GetResult) {
+func GetIsSuccessful(t *testing.T, result tokens.GetResult) {
token, err := result.ExtractToken()
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, ExpectedToken, token)
diff --git a/openstack/identity/v2/tokens/requests_test.go b/openstack/identity/v2/tokens/testing/requests_test.go
similarity index 84%
rename from openstack/identity/v2/tokens/requests_test.go
rename to openstack/identity/v2/tokens/testing/requests_test.go
index a6d16f3..b687a92 100644
--- a/openstack/identity/v2/tokens/requests_test.go
+++ b/openstack/identity/v2/tokens/testing/requests_test.go
@@ -1,19 +1,20 @@
-package tokens
+package testing
import (
"testing"
"github.com/gophercloud/gophercloud"
+ "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens"
th "github.com/gophercloud/gophercloud/testhelper"
"github.com/gophercloud/gophercloud/testhelper/client"
)
-func tokenPost(t *testing.T, options gophercloud.AuthOptions, requestJSON string) CreateResult {
+func tokenPost(t *testing.T, options gophercloud.AuthOptions, requestJSON string) tokens.CreateResult {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleTokenPost(t, requestJSON)
- return Create(client.ServiceClient(), options)
+ return tokens.Create(client.ServiceClient(), options)
}
func tokenPostErr(t *testing.T, options gophercloud.AuthOptions, expectedErr error) {
@@ -21,7 +22,7 @@
defer th.TeardownHTTP()
HandleTokenPost(t, "")
- actualErr := Create(client.ServiceClient(), options).Err
+ actualErr := tokens.Create(client.ServiceClient(), options).Err
th.CheckDeepEquals(t, expectedErr, actualErr)
}
@@ -91,11 +92,11 @@
tokenPostErr(t, options, gophercloud.ErrMissingInput{Argument: "Username"})
}
-func tokenGet(t *testing.T, tokenId string) GetResult {
+func tokenGet(t *testing.T, tokenId string) tokens.GetResult {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleTokenGet(t, tokenId)
- return Get(client.ServiceClient(), tokenId)
+ return tokens.Get(client.ServiceClient(), tokenId)
}
func TestGetWithToken(t *testing.T) {