summaryrefslogtreecommitdiff
path: root/internal/api/client/media/mediacreate_test.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2021-09-12 10:10:24 +0100
committerLibravatar GitHub <noreply@github.com>2021-09-12 10:10:24 +0100
commitf6492d12d948507021bbe934de94e87e20464c01 (patch)
tree6705d6ef6f3c4d70f3b3ebc77c2960d8e508cf37 /internal/api/client/media/mediacreate_test.go
parentMerge pull request #213 from superseriousbusiness/alpine+node_upstep (diff)
parentfix keys used to access storage items (diff)
downloadgotosocial-f6492d12d948507021bbe934de94e87e20464c01.tar.xz
Merge pull request #214 from NyaaaWhatsUpDoc/improvement/update-storage-library
add git.iim.gay/grufwub/go-store for storage backend, replacing blob.Storage
Diffstat (limited to 'internal/api/client/media/mediacreate_test.go')
-rw-r--r--internal/api/client/media/mediacreate_test.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/internal/api/client/media/mediacreate_test.go b/internal/api/client/media/mediacreate_test.go
index 1b2c84cf9..53c1ce996 100644
--- a/internal/api/client/media/mediacreate_test.go
+++ b/internal/api/client/media/mediacreate_test.go
@@ -28,13 +28,13 @@ import (
"net/http/httptest"
"testing"
+ "git.iim.gay/grufwub/go-store/kv"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
mediamodule "github.com/superseriousbusiness/gotosocial/internal/api/client/media"
"github.com/superseriousbusiness/gotosocial/internal/api/model"
- "github.com/superseriousbusiness/gotosocial/internal/blob"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/federation"
@@ -52,7 +52,7 @@ type MediaCreateTestSuite struct {
config *config.Config
db db.DB
log *logrus.Logger
- storage blob.Storage
+ storage *kv.KVStore
federator federation.Federator
tc typeutils.TypeConverter
mediaHandler media.Handler
@@ -118,7 +118,6 @@ func (suite *MediaCreateTestSuite) TearDownTest() {
*/
func (suite *MediaCreateTestSuite) TestStatusCreatePOSTImageHandlerSuccessful() {
-
// set up the context for the request
t := suite.testTokens["local_account_1"]
oauthToken := oauth.DBTokenToToken(t)
@@ -130,10 +129,15 @@ func (suite *MediaCreateTestSuite) TestStatusCreatePOSTImageHandlerSuccessful()
ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["local_account_1"])
// see what's in storage *before* the request
- storageKeysBeforeRequest, err := suite.storage.ListKeys()
+ storageKeysBeforeRequest := []string{}
+ iter, err := suite.storage.Iterator(nil)
if 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{
@@ -150,10 +154,15 @@ func (suite *MediaCreateTestSuite) TestStatusCreatePOSTImageHandlerSuccessful()
suite.mediaModule.MediaCreatePOSTHandler(ctx)
// check what's in storage *after* the request
- storageKeysAfterRequest, err := suite.storage.ListKeys()
+ storageKeysAfterRequest := []string{}
+ iter, err = suite.storage.Iterator(nil)
if err != nil {
panic(err)
}
+ for iter.Next() {
+ storageKeysAfterRequest = append(storageKeysAfterRequest, iter.Key())
+ }
+ iter.Release()
// check response
suite.EqualValues(http.StatusOK, recorder.Code)