aboutsummaryrefslogtreecommitdiff
path: root/tests/shared_test.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-07-21 14:24:35 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-07-21 14:42:45 +0200
commit9bcfd4733a7ae7d12129b024e93536f7136e4a8e (patch)
treefaac942c4d7780fd5f41e2871ea030ff37328cae /tests/shared_test.go
parent044e297413066262c54beb33e98d0e498178897b (diff)
downloadgo-schwift-9bcfd4733a7ae7d12129b024e93536f7136e4a8e.tar.gz
use t.Context() instead of context.TODO() in tests
Diffstat (limited to 'tests/shared_test.go')
-rw-r--r--tests/shared_test.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/tests/shared_test.go b/tests/shared_test.go
index 4bef612..9ff9053 100644
--- a/tests/shared_test.go
+++ b/tests/shared_test.go
@@ -19,7 +19,6 @@
package tests
import (
- "context"
"crypto/md5" //nolint:gosec // Etag uses md5
"crypto/rand"
"encoding/hex"
@@ -44,7 +43,7 @@ func testWithAccount(t *testing.T, testCode func(a *schwift.Account)) {
if stAuth == "" && stUser == "" && stKey == "" {
// option 1: Keystone authentication
- provider, err := clientconfig.AuthenticatedClient(context.TODO(), nil)
+ provider, err := clientconfig.AuthenticatedClient(t.Context(), nil)
if err != nil {
t.Error("clientconfig.AuthenticatedClient returned: " + err.Error())
t.Error("probably missing Swift credentials (need either ST_AUTH, ST_USER, ST_KEY or OS_* variables)")
@@ -62,7 +61,7 @@ func testWithAccount(t *testing.T, testCode func(a *schwift.Account)) {
t.Error("openstack.NewClient returned: " + err.Error())
return
}
- client, err = swauth.NewObjectStorageV1(context.TODO(), provider, swauth.AuthOpts{User: stUser, Key: stKey})
+ client, err = swauth.NewObjectStorageV1(t.Context(), provider, swauth.AuthOpts{User: stUser, Key: stKey})
if err != nil {
t.Error("swauth.NewObjectStorageV1 returned: " + err.Error())
return
@@ -87,19 +86,19 @@ func testWithAccount(t *testing.T, testCode func(a *schwift.Account)) {
func testWithContainer(t *testing.T, testCode func(c *schwift.Container)) {
testWithAccount(t, func(a *schwift.Account) {
containerName := getRandomName()
- container, err := a.Container(containerName).EnsureExists(context.TODO())
+ container, err := a.Container(containerName).EnsureExists(t.Context())
expectSuccess(t, err)
testCode(container)
// cleanup
- exists, err := container.Exists(context.TODO())
+ exists, err := container.Exists(t.Context())
expectSuccess(t, err)
if exists {
- expectSuccess(t, container.Objects().Foreach(context.TODO(), func(o *schwift.Object) error {
- return o.Delete(context.TODO(), nil, nil)
+ expectSuccess(t, container.Objects().Foreach(t.Context(), func(o *schwift.Object) error {
+ return o.Delete(t.Context(), nil, nil)
}))
- err = container.Delete(context.TODO(), nil)
+ err = container.Delete(t.Context(), nil)
expectSuccess(t, err)
}
})