summaryrefslogtreecommitdiff
path: root/internal/api/client/media/mediacreate_test.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-03-01 09:44:54 +0000
committerLibravatar GitHub <noreply@github.com>2023-03-01 10:44:54 +0100
commit87c5c4297284791ca60ee9eccc4d685b05013272 (patch)
tree04572ef24e5943eead505219e1f8097a9829a550 /internal/api/client/media/mediacreate_test.go
parent[chore] Improve unsupported_grant_type error (#1572) (diff)
downloadgotosocial-87c5c4297284791ca60ee9eccc4d685b05013272.tar.xz
[chore/performance] simplify storage driver to use storage.Storage directly (#1576)
* simply use storage.Storage, removing wrapping KVStore as we don't need KV store locking functionality Signed-off-by: kim <grufwub@gmail.com> * fix missing unwrapped function Signed-off-by: kim <grufwub@gmail.com> * add code comment Signed-off-by: kim <grufwub@gmail.com> * linter, please take my offering in peace Signed-off-by: kim <grufwub@gmail.com> --------- Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/api/client/media/mediacreate_test.go')
-rw-r--r--internal/api/client/media/mediacreate_test.go48
1 files changed, 20 insertions, 28 deletions
diff --git a/internal/api/client/media/mediacreate_test.go b/internal/api/client/media/mediacreate_test.go
index aaace7a61..caa40b061 100644
--- a/internal/api/client/media/mediacreate_test.go
+++ b/internal/api/client/media/mediacreate_test.go
@@ -136,15 +136,13 @@ func (suite *MediaCreateTestSuite) TestMediaCreateSuccessful() {
ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["local_account_1"])
// see what's in storage *before* the request
- storageKeysBeforeRequest := []string{}
- iter, err := suite.storage.KVStore.Iterator(context.Background(), nil)
- if err != nil {
+ var storageKeysBeforeRequest []string
+ if err := suite.storage.WalkKeys(ctx, func(ctx context.Context, key string) error {
+ storageKeysBeforeRequest = append(storageKeysBeforeRequest, key)
+ return nil
+ }); err != nil {
panic(err)
}
- for iter.Next() {
- storageKeysBeforeRequest = append(storageKeysBeforeRequest, iter.Key())
- }
- iter.Release()
// create the request
buf, w, err := testrig.CreateMultipartFormData("file", "../../../../testrig/media/test-jpeg.jpg", map[string]string{
@@ -163,15 +161,13 @@ func (suite *MediaCreateTestSuite) TestMediaCreateSuccessful() {
suite.mediaModule.MediaCreatePOSTHandler(ctx)
// check what's in storage *after* the request
- storageKeysAfterRequest := []string{}
- iter, err = suite.storage.KVStore.Iterator(context.Background(), nil)
- if err != nil {
+ var storageKeysAfterRequest []string
+ if err := suite.storage.WalkKeys(ctx, func(ctx context.Context, key string) error {
+ storageKeysAfterRequest = append(storageKeysAfterRequest, key)
+ return nil
+ }); err != nil {
panic(err)
}
- for iter.Next() {
- storageKeysAfterRequest = append(storageKeysAfterRequest, iter.Key())
- }
- iter.Release()
// check response
suite.EqualValues(http.StatusOK, recorder.Code)
@@ -225,15 +221,13 @@ func (suite *MediaCreateTestSuite) TestMediaCreateSuccessfulV2() {
ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["local_account_1"])
// see what's in storage *before* the request
- storageKeysBeforeRequest := []string{}
- iter, err := suite.storage.KVStore.Iterator(context.Background(), nil)
- if err != nil {
+ var storageKeysBeforeRequest []string
+ if err := suite.storage.WalkKeys(ctx, func(ctx context.Context, key string) error {
+ storageKeysBeforeRequest = append(storageKeysBeforeRequest, key)
+ return nil
+ }); err != nil {
panic(err)
}
- for iter.Next() {
- storageKeysBeforeRequest = append(storageKeysBeforeRequest, iter.Key())
- }
- iter.Release()
// create the request
buf, w, err := testrig.CreateMultipartFormData("file", "../../../../testrig/media/test-jpeg.jpg", map[string]string{
@@ -252,15 +246,13 @@ func (suite *MediaCreateTestSuite) TestMediaCreateSuccessfulV2() {
suite.mediaModule.MediaCreatePOSTHandler(ctx)
// check what's in storage *after* the request
- storageKeysAfterRequest := []string{}
- iter, err = suite.storage.KVStore.Iterator(context.Background(), nil)
- if err != nil {
+ var storageKeysAfterRequest []string
+ if err := suite.storage.WalkKeys(ctx, func(ctx context.Context, key string) error {
+ storageKeysAfterRequest = append(storageKeysAfterRequest, key)
+ return nil
+ }); err != nil {
panic(err)
}
- for iter.Next() {
- storageKeysAfterRequest = append(storageKeysAfterRequest, iter.Key())
- }
- iter.Release()
// check response
suite.EqualValues(http.StatusOK, recorder.Code)