openstack object storage acceptance tests fixes
diff --git a/acceptance/openstack/objectstorage/v1/accounts_test.go b/acceptance/openstack/objectstorage/v1/accounts_test.go
index 0cbee04..f7c01a7 100644
--- a/acceptance/openstack/objectstorage/v1/accounts_test.go
+++ b/acceptance/openstack/objectstorage/v1/accounts_test.go
@@ -16,8 +16,8 @@
client := newClient(t)
// Update an account's metadata.
- res = accounts.Update(client, accounts.UpdateOpts{Metadata: metadata})
- th.AssertNoErr(t, res.Err)
+ updateres := accounts.Update(client, accounts.UpdateOpts{Metadata: metadata})
+ th.AssertNoErr(t, updateres.Err)
// Defer the deletion of the metadata set above.
defer func() {
@@ -25,15 +25,16 @@
for k := range metadata {
tempMap[k] = ""
}
- res = accounts.Update(client, accounts.UpdateOpts{Metadata: tempMap})
- th.AssertNoErr(t, res.Err)
+ updateres = accounts.Update(client, accounts.UpdateOpts{Metadata: tempMap})
+ th.AssertNoErr(t, updateres.Err)
}()
// Retrieve account metadata.
- res := accounts.Get(client, accounts.GetOpts{})
- th.AssertNoErr(res.Err)
+ getres := accounts.Get(client, nil)
+ th.AssertNoErr(t, getres.Err)
// Extract the custom metadata from the 'Get' response.
- am := accounts.ExtractMetadata(gr)
+ am, err := getres.ExtractMetadata()
+ th.AssertNoErr(t, err)
for k := range metadata {
if am[k] != metadata[strings.Title(k)] {
t.Errorf("Expected custom metadata with key: %s", k)
diff --git a/acceptance/openstack/objectstorage/v1/common.go b/acceptance/openstack/objectstorage/v1/common.go
index a91f9c7..1eac681 100644
--- a/acceptance/openstack/objectstorage/v1/common.go
+++ b/acceptance/openstack/objectstorage/v1/common.go
@@ -20,7 +20,9 @@
client, err := openstack.AuthenticatedClient(ao)
th.AssertNoErr(t, err)
- return openstack.NewObjectStorageV1(client, gophercloud.EndpointOpts{
+ c, err := openstack.NewObjectStorageV1(client, gophercloud.EndpointOpts{
Region: os.Getenv("OS_REGION_NAME"),
})
+ th.AssertNoErr(t, err)
+ return c
}
diff --git a/acceptance/openstack/objectstorage/v1/containers_test.go b/acceptance/openstack/objectstorage/v1/containers_test.go
index 8856941..d6832f1 100644
--- a/acceptance/openstack/objectstorage/v1/containers_test.go
+++ b/acceptance/openstack/objectstorage/v1/containers_test.go
@@ -28,21 +28,21 @@
// Create numContainers containers.
for i := 0; i < len(cNames); i++ {
res := containers.Create(client, cNames[i], nil)
- th.AssertNoErr(res.Err)
+ th.AssertNoErr(t, res.Err)
}
// Delete the numContainers containers after function completion.
defer func() {
for i := 0; i < len(cNames); i++ {
- res = containers.Delete(client, cNames[i])
- th.AssertNoErr(res.Err)
+ res := containers.Delete(client, cNames[i])
+ th.AssertNoErr(t, res.Err)
}
}()
// List the numContainer names that were just created. To just list those,
// the 'prefix' parameter is used.
- err = containers.List(client, &containers.ListOpts{Full: true, Prefix: "gophercloud-test-container-"}).EachPage(func(page pagination.Page) (bool, error) {
+ err := containers.List(client, &containers.ListOpts{Full: true, Prefix: "gophercloud-test-container-"}).EachPage(func(page pagination.Page) (bool, error) {
containerList, err := containers.ExtractInfo(page)
- th.AssertNoErr(err)
+ th.AssertNoErr(t, err)
for _, n := range containerList {
t.Logf("Container: Name [%s] Count [%d] Bytes [%d]",
@@ -51,36 +51,36 @@
return true, nil
})
- th.AssertNoErr(err)
+ th.AssertNoErr(t, err)
// List the info for the numContainer containers that were created.
err = containers.List(client, &containers.ListOpts{Full: false, Prefix: "gophercloud-test-container-"}).EachPage(func(page pagination.Page) (bool, error) {
containerList, err := containers.ExtractNames(page)
- th.AssertNoErr(err)
+ th.AssertNoErr(t, err)
for _, n := range containerList {
t.Logf("Container: Name [%s]", n)
}
return true, nil
})
- th.AssertNoErr(err)
+ th.AssertNoErr(t, err)
// Update one of the numContainer container metadata.
- res = containers.Update(client, cNames[0], &containers.UpdateOpts{Metadata: metadata})
- th.AssertNoErr(res.Err)
+ updateres := containers.Update(client, cNames[0], &containers.UpdateOpts{Metadata: metadata})
+ th.AssertNoErr(t, updateres.Err)
// After the tests are done, delete the metadata that was set.
defer func() {
tempMap := make(map[string]string)
for k := range metadata {
tempMap[k] = ""
}
- res = containers.Update(client, cNames[0], &containers.UpdateOpts{Metadata: tempMap})
- th.AssertNoErr(res.Err)
+ res := containers.Update(client, cNames[0], &containers.UpdateOpts{Metadata: tempMap})
+ th.AssertNoErr(t, res.Err)
}()
// Retrieve a container's metadata.
cm, err := containers.Get(client, cNames[0]).ExtractMetadata()
- th.AssertNoErr(err)
+ th.AssertNoErr(t, err)
for k := range metadata {
if cm[k] != metadata[strings.Title(k)] {
t.Errorf("Expected custom metadata with key: %s", k)
diff --git a/acceptance/openstack/objectstorage/v1/objects_test.go b/acceptance/openstack/objectstorage/v1/objects_test.go
index 4c47367..987f733 100644
--- a/acceptance/openstack/objectstorage/v1/objects_test.go
+++ b/acceptance/openstack/objectstorage/v1/objects_test.go
@@ -20,7 +20,7 @@
func TestObjects(t *testing.T) {
// Create a provider client for executing the HTTP request.
// See common.go for more information.
- client := newClient()
+ client := newClient(t)
// Make a slice of length numObjects to hold the random object names.
oNames := make([]string, numObjects)
@@ -30,79 +30,71 @@
// Create a container to hold the test objects.
cName := tools.RandomString("test-container-", 8)
- res = containers.Create(client, cName, nil)
- th.AssertNoErr(res.Err)
+ createres := containers.Create(client, cName, nil)
+ th.AssertNoErr(t, createres.Err)
// Defer deletion of the container until after testing.
defer func() {
- res = containers.Delete(client, cName)
- th.AssertNoErr(res.Err)
+ res := containers.Delete(client, cName)
+ th.AssertNoErr(t, res.Err)
}()
// Create a slice of buffers to hold the test object content.
oContents := make([]*bytes.Buffer, numObjects)
for i := 0; i < numObjects; i++ {
oContents[i] = bytes.NewBuffer([]byte(tools.RandomString("", 10)))
- res = objects.Create(client, cName, oNames[i], oContents[i], nil)
- th.AssertNoErr(res.Err)
+ res := objects.Create(client, cName, oNames[i], oContents[i], nil)
+ th.AssertNoErr(t, res.Err)
}
// Delete the objects after testing.
defer func() {
for i := 0; i < numObjects; i++ {
- res = objects.Delete(client, cName, oNames[i], nil)
+ res := objects.Delete(client, cName, oNames[i], nil)
+ th.AssertNoErr(t, res.Err)
}
}()
ons := make([]string, 0, len(oNames))
- err = objects.List(client, cName, &objects.ListOpts{Full: false, Prefix: "test-object-"}).EachPage(func(page pagination.Page) (bool, error) {
+ err := objects.List(client, cName, &objects.ListOpts{Full: false, Prefix: "test-object-"}).EachPage(func(page pagination.Page) (bool, error) {
names, err := objects.ExtractNames(page)
- th.AssertNoErr(err)
+ th.AssertNoErr(t, err)
ons = append(ons, names...)
return true, nil
})
- th.AssertNoErr(err)
- if len(ons) != len(oNames) {
- t.Errorf("Expected %d names and got %d", len(oNames), len(ons))
- return
- }
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, len(ons), len(oNames))
ois := make([]objects.Object, 0, len(oNames))
err = objects.List(client, cName, &objects.ListOpts{Full: true, Prefix: "test-object-"}).EachPage(func(page pagination.Page) (bool, error) {
info, err := objects.ExtractInfo(page)
- th.AssertNoErr(err)
+ th.AssertNoErr(t, err)
ois = append(ois, info...)
return true, nil
})
- th.AssertNoErr(err)
- if len(ois) != len(oNames) {
- t.Errorf("Expected %d containers and got %d", len(oNames), len(ois))
- return
- }
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, len(ois), len(oNames))
// Copy the contents of one object to another.
- res = objects.Copy(client, cName, oNames[0], &objects.CopyOpts{Destination: cName + "/" + oNames[1]})
- th.AssertNoErr(res.Err)
+ copyres := objects.Copy(client, cName, oNames[0], &objects.CopyOpts{Destination: cName + "/" + oNames[1]})
+ th.AssertNoErr(t, copyres.Err)
// Download one of the objects that was created above.
o1Content, err := objects.Download(client, cName, oNames[0], nil).ExtractContent()
- th.AssertNoErr(err)
+ th.AssertNoErr(t, err)
// Download the another object that was create above.
o2Content, err := objects.Download(client, cName, oNames[1], nil).ExtractContent()
- th.AssertNoErr(err)
+ th.AssertNoErr(t, err)
// Compare the two object's contents to test that the copy worked.
- if string(o2Content) != string(o1Content) {
- t.Errorf("Copy failed. Expected\n%s\nand got\n%s", string(o1Content), string(o2Content))
- return
- }
+ th.AssertEquals(t, string(o2Content), string(o1Content))
// Update an object's metadata.
- res = objects.Update(client, cName, oNames[0], &objects.UpdateOpts{Metadata: metadata})
- th.AssertNoErr(res.Err)
+ updateres := objects.Update(client, cName, oNames[0], &objects.UpdateOpts{Metadata: metadata})
+ th.AssertNoErr(t, updateres.Err)
// Delete the object's metadata after testing.
defer func() {
@@ -110,13 +102,13 @@
for k := range metadata {
tempMap[k] = ""
}
- res = objects.Update(client, cName, oNames[0], &objects.UpdateOpts{Metadata: tempMap})
- th.AssertNoErr(res.Err)
+ res := objects.Update(client, cName, oNames[0], &objects.UpdateOpts{Metadata: tempMap})
+ th.AssertNoErr(t, res.Err)
}()
// Retrieve an object's metadata.
om, err := objects.Get(client, cName, oNames[0], nil).ExtractMetadata()
- th.AssertNoErr(err)
+ th.AssertNoErr(t, err)
for k := range metadata {
if om[k] != metadata[strings.Title(k)] {
t.Errorf("Expected custom metadata with key: %s", k)