aboutsummaryrefslogtreecommitdiff
path: root/tests/container_test.go
diff options
context:
space:
mode:
authorStefan Majewsky <stefan.majewsky@sap.com>2024-07-08 15:43:52 +0200
committerGitHub <noreply@github.com>2024-07-08 15:43:52 +0200
commit4fac97b5e944ce70cdca3679f5c2b1eef9b83952 (patch)
treefcf486f49df855f2803981c753ed775b1305f6c8 /tests/container_test.go
parent5a783c56a98c225569abfa6fb12fdf55297fee9e (diff)
parentb7683ab8dcdeca10ff52d626a285edcf7c1db719 (diff)
downloadgo-schwift-4fac97b5e944ce70cdca3679f5c2b1eef9b83952.tar.gz
Merge pull request #19 from SuperSandro2000/context
Remove context from struct, add ctx as first args to many functions
Diffstat (limited to 'tests/container_test.go')
-rw-r--r--tests/container_test.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/tests/container_test.go b/tests/container_test.go
index da05506..0ddd3bb 100644
--- a/tests/container_test.go
+++ b/tests/container_test.go
@@ -19,6 +19,7 @@
package tests
import (
+ "context"
"fmt"
"net/http"
"testing"
@@ -36,35 +37,35 @@ func TestContainerLifecycle(t *testing.T) {
t.Errorf("expected c.Account() = %#v, got %#v instead\n", a, c.Account())
}
- exists, err := c.Exists()
+ exists, err := c.Exists(context.TODO())
expectSuccess(t, err)
expectBool(t, exists, false)
- _, err = c.Headers()
+ _, err = c.Headers(context.TODO())
expectError(t, err, fmt.Sprintf("could not HEAD %q in Swift: expected 204 response, got 404 instead", containerName))
expectBool(t, schwift.Is(err, http.StatusNotFound), true)
expectBool(t, schwift.Is(err, http.StatusNoContent), false)
// DELETE should be idempotent and not return success on non-existence, but
// OpenStack LOVES to be inconsistent with everything (including, notably, itself)
- err = c.Delete(nil)
+ err = c.Delete(context.TODO(), nil)
expectError(t, err, fmt.Sprintf("could not DELETE %q in Swift: expected 204 response, got 404 instead: <html><h1>Not Found</h1><p>The resource could not be found.</p></html>", containerName))
- err = c.Create(nil)
+ err = c.Create(context.TODO(), nil)
expectSuccess(t, err)
- exists, err = c.Exists()
+ exists, err = c.Exists(context.TODO())
expectSuccess(t, err)
expectBool(t, exists, true)
- err = c.Delete(nil)
+ err = c.Delete(context.TODO(), nil)
expectSuccess(t, err)
})
}
func TestContainerUpdate(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
- hdr, err := c.Headers()
+ hdr, err := c.Headers(context.TODO())
expectSuccess(t, err)
expectBool(t, hdr.ObjectCount().Exists(), true)
expectUint64(t, hdr.ObjectCount().Get(), 0)
@@ -73,10 +74,10 @@ func TestContainerUpdate(t *testing.T) {
hdr.ObjectCountQuota().Set(23)
hdr.BytesUsedQuota().Set(42)
- err = c.Update(hdr, nil)
+ err = c.Update(context.TODO(), hdr, nil)
expectSuccess(t, err)
- hdr, err = c.Headers()
+ hdr, err = c.Headers(context.TODO())
expectSuccess(t, err)
expectUint64(t, hdr.BytesUsedQuota().Get(), 42)
expectUint64(t, hdr.ObjectCountQuota().Get(), 23)
@@ -86,7 +87,7 @@ func TestContainerUpdate(t *testing.T) {
func expectContainerExistence(t *testing.T, c *schwift.Container, expectedExists bool) {
t.Helper()
c.Invalidate()
- actualExists, err := c.Exists()
+ actualExists, err := c.Exists(context.TODO())
expectSuccess(t, err)
expectBool(t, actualExists, expectedExists)
}