Acceptance Test Updates (#218)
* compute: don't pass choices
* blockstorage: don't pass choices
* DumpResource Function
This function prints a resource in JSON format but retains the actual
field name rather than using the name specified in the JSON tag.
* New DumpResource
This version just converts the resource into JSON. The original is
being left in git history for posterity.
* Renaming DumpResource to PrintResource
* Removing all print functions in favor of PrintResource
* Rebase reconcilliation
diff --git a/acceptance/openstack/identity/v2/extension_test.go b/acceptance/openstack/identity/v2/extension_test.go
index 3e526f1..c6a2bde 100644
--- a/acceptance/openstack/identity/v2/extension_test.go
+++ b/acceptance/openstack/identity/v2/extension_test.go
@@ -6,7 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
- "github.com/gophercloud/gophercloud/acceptance/openstack"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/identity/v2/extensions"
)
@@ -27,7 +27,7 @@
}
for _, extension := range allExtensions {
- openstack.PrintExtension(t, &extension)
+ tools.PrintResource(t, extension)
}
}
@@ -42,5 +42,5 @@
t.Fatalf("Unable to get extension OS-KSCRUD: %v", err)
}
- openstack.PrintExtension(t, extension)
+ tools.PrintResource(t, extension)
}
diff --git a/acceptance/openstack/identity/v2/identity.go b/acceptance/openstack/identity/v2/identity.go
index f1c6624..2d3bd09 100644
--- a/acceptance/openstack/identity/v2/identity.go
+++ b/acceptance/openstack/identity/v2/identity.go
@@ -9,7 +9,6 @@
"github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/identity/v2/extensions/admin/roles"
"github.com/gophercloud/gophercloud/openstack/identity/v2/tenants"
- "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens"
"github.com/gophercloud/gophercloud/openstack/identity/v2/users"
)
@@ -145,72 +144,3 @@
return newUser, nil
}
-
-// PrintCatalogEntry will print a catalog entry and all of its attributes.
-func PrintCatalogEntry(t *testing.T, catalogEntry *tokens.CatalogEntry) {
- t.Logf("Name: %s", catalogEntry.Name)
- t.Logf("Type: %s", catalogEntry.Type)
-
- t.Log("Endpoints:")
- for _, endpoint := range catalogEntry.Endpoints {
- t.Logf("\tTenantID: %s", endpoint.TenantID)
- t.Logf("\tPublicURL: %s", endpoint.PublicURL)
- t.Logf("\tInternalURL: %s", endpoint.InternalURL)
- t.Logf("\tAdminURL: %s", endpoint.AdminURL)
- t.Logf("\tRegion: %s", endpoint.Region)
- t.Logf("\tVersionID: %s", endpoint.VersionID)
- t.Logf("\tVersionInfo: %s", endpoint.VersionInfo)
- t.Logf("\tVersionList: %s", endpoint.VersionList)
- }
-}
-
-// PrintRole will print a role and all of its attributes.
-func PrintRole(t *testing.T, role *roles.Role) {
- t.Logf("ID: %s", role.ID)
- t.Logf("Name: %v", role.Name)
- t.Logf("Description: %s", role.Description)
- t.Logf("ServiceID: %s", role.ServiceID)
-}
-
-// PrintTenant will print a tenant and all of its attributes.
-func PrintTenant(t *testing.T, tenant *tenants.Tenant) {
- t.Logf("ID: %s", tenant.ID)
- t.Logf("Name: %s", tenant.Name)
- t.Logf("Description: %s", tenant.Description)
- t.Logf("Enabled: %t", tenant.Enabled)
-}
-
-// PrintToken will print a token and all of its attributes.
-func PrintToken(t *testing.T, token *tokens.Token) {
- t.Logf("ID: %s", token.ID)
- t.Logf("ExpiresAt: %v", token.ExpiresAt)
- t.Logf("TenantID: %s", token.Tenant.ID)
-}
-
-// PrintTokenUser will print the user information of a token and all attributes.
-func PrintTokenUser(t *testing.T, user *tokens.User) {
- t.Logf("ID: %s", user.ID)
- t.Logf("Name: %s", user.Name)
- t.Logf("Username: %s", user.UserName)
-
- t.Log("Roles")
- for _, role := range user.Roles {
- t.Logf("\t%s", role)
- }
-}
-
-// PrintUser will print a user and all of its attributes.
-func PrintUser(t *testing.T, user *users.User) {
- t.Logf("ID: %s", user.ID)
- t.Logf("Name: %s", user.Name)
- t.Logf("Username: %s", user.Username)
- t.Logf("Enabled: %t", user.Enabled)
- t.Logf("Email: %s", user.Email)
- t.Logf("TenantID: %s", user.TenantID)
-}
-
-// PrintUserRole will print the roles that a user has been granted.
-func PrintUserRole(t *testing.T, role *users.Role) {
- t.Logf("ID: %s", role.ID)
- t.Logf("Name: %s", role.Name)
-}
diff --git a/acceptance/openstack/identity/v2/role_test.go b/acceptance/openstack/identity/v2/role_test.go
index 5589b1b..83fbd31 100644
--- a/acceptance/openstack/identity/v2/role_test.go
+++ b/acceptance/openstack/identity/v2/role_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/identity/v2/extensions/admin/roles"
"github.com/gophercloud/gophercloud/openstack/identity/v2/users"
)
@@ -50,7 +51,7 @@
t.Logf("Roles of user %s:", user.Name)
for _, role := range allRoles {
- PrintUserRole(t, &role)
+ tools.PrintResource(t, role)
}
}
@@ -71,6 +72,6 @@
}
for _, r := range allRoles {
- PrintRole(t, &r)
+ tools.PrintResource(t, r)
}
}
diff --git a/acceptance/openstack/identity/v2/tenant_test.go b/acceptance/openstack/identity/v2/tenant_test.go
index ed457d4..2053614 100644
--- a/acceptance/openstack/identity/v2/tenant_test.go
+++ b/acceptance/openstack/identity/v2/tenant_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/identity/v2/tenants"
)
@@ -26,6 +27,6 @@
}
for _, tenant := range allTenants {
- PrintTenant(t, &tenant)
+ tools.PrintResource(t, tenant)
}
}
diff --git a/acceptance/openstack/identity/v2/token_test.go b/acceptance/openstack/identity/v2/token_test.go
index 4cd8301..82a317a 100644
--- a/acceptance/openstack/identity/v2/token_test.go
+++ b/acceptance/openstack/identity/v2/token_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack"
"github.com/gophercloud/gophercloud/openstack/identity/v2/tokens"
)
@@ -27,7 +28,7 @@
t.Fatalf("Unable to extract token: %v", err)
}
- PrintToken(t, token)
+ tools.PrintResource(t, token)
catalog, err := result.ExtractServiceCatalog()
if err != nil {
@@ -35,7 +36,7 @@
}
for _, entry := range catalog.Entries {
- PrintCatalogEntry(t, &entry)
+ tools.PrintResource(t, entry)
}
}
@@ -56,7 +57,7 @@
t.Fatalf("Unable to extract token: %v", err)
}
- PrintToken(t, token)
+ tools.PrintResource(t, token)
getResult := tokens.Get(client, token.ID)
user, err := getResult.ExtractUser()
@@ -64,5 +65,5 @@
t.Fatalf("Unable to extract user: %v", err)
}
- PrintTokenUser(t, user)
+ tools.PrintResource(t, user)
}
diff --git a/acceptance/openstack/identity/v2/user_test.go b/acceptance/openstack/identity/v2/user_test.go
index 5c6bfd9..faa5bba 100644
--- a/acceptance/openstack/identity/v2/user_test.go
+++ b/acceptance/openstack/identity/v2/user_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/identity/v2/users"
)
@@ -26,7 +27,7 @@
}
for _, user := range allUsers {
- PrintUser(t, &user)
+ tools.PrintResource(t, user)
}
}
@@ -47,12 +48,12 @@
}
defer DeleteUser(t, client, user)
- PrintUser(t, user)
+ tools.PrintResource(t, user)
newUser, err := UpdateUser(t, client, user)
if err != nil {
t.Fatalf("Unable to update user: %v", err)
}
- PrintUser(t, newUser)
+ tools.PrintResource(t, newUser)
}