use th.AssertNoErr
diff --git a/acceptance/openstack/blockstorage/v1/volumes_test.go b/acceptance/openstack/blockstorage/v1/volumes_test.go
index 924a95d..99da39a 100644
--- a/acceptance/openstack/blockstorage/v1/volumes_test.go
+++ b/acceptance/openstack/blockstorage/v1/volumes_test.go
@@ -10,18 +10,15 @@
"github.com/rackspace/gophercloud/openstack"
"github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes"
"github.com/rackspace/gophercloud/pagination"
+ th "github.com/rackspace/gophercloud/testhelper"
)
func newClient() (*gophercloud.ServiceClient, error) {
ao, err := openstack.AuthOptionsFromEnv()
- if err != nil {
- return nil, err
- }
+ th.AssertNoErr(t, err)
client, err := openstack.AuthenticatedClient(ao)
- if err != nil {
- return nil, err
- }
+ th.AssertNoErr(t, err)
return openstack.NewBlockStorageV1(client, gophercloud.EndpointOpts{
Region: os.Getenv("OS_REGION_NAME"),
@@ -30,43 +27,27 @@
func TestVolumes(t *testing.T) {
client, err := newClient()
- if err != nil {
- t.Fatalf("Failed to create Block Storage v1 client: %v", err)
- }
+ th.AssertNoErr(t, err)
cv, err := volumes.Create(client, &volumes.CreateOpts{
Size: 1,
Name: "gophercloud-test-volume",
}).Extract()
- if err != nil {
- t.Error(err)
- return
- }
+ th.AssertNoErr(t, err)
defer func() {
err = volumes.WaitForStatus(client, cv.ID, "available", 60)
- if err != nil {
- t.Error(err)
- }
+ th.AssertNoErr(t, err)
err = volumes.Delete(client, cv.ID).ExtractErr()
- if err != nil {
- t.Error(err)
- return
- }
+ th.AssertNoErr(t, err)
}()
_, err = volumes.Update(client, cv.ID, &volumes.UpdateOpts{
Name: "gophercloud-updated-volume",
}).Extract()
- if err != nil {
- t.Error(err)
- return
- }
+ th.AssertNoErr(t, err)
v, err := volumes.Get(client, cv.ID).Extract()
- if err != nil {
- t.Error(err)
- return
- }
+ th.AssertNoErr(t, err)
t.Logf("Got volume: %+v\n", v)
if v.Name != "gophercloud-updated-volume" {
@@ -75,12 +56,8 @@
err = volumes.List(client, &volumes.ListOpts{Name: "gophercloud-updated-volume"}).EachPage(func(page pagination.Page) (bool, error) {
vols, err := volumes.ExtractVolumes(page)
- if len(vols) != 1 {
- t.Errorf("Expected 1 volume, got %d", len(vols))
- }
+ th.CheckEquals(t, 1, len(vols))
return true, err
})
- if err != nil {
- t.Errorf("Error listing volumes: %v", err)
- }
+ th.AssertNoErr(t, err)
}