summaryrefslogtreecommitdiff
path: root/testrig/storage.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 /testrig/storage.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 'testrig/storage.go')
-rw-r--r--testrig/storage.go24
1 files changed, 5 insertions, 19 deletions
diff --git a/testrig/storage.go b/testrig/storage.go
index 5694b3ab6..4bbf02696 100644
--- a/testrig/storage.go
+++ b/testrig/storage.go
@@ -24,7 +24,6 @@ import (
"os"
"path"
- "codeberg.org/gruf/go-store/v2/kv"
"codeberg.org/gruf/go-store/v2/storage"
gtsstorage "github.com/superseriousbusiness/gotosocial/internal/storage"
)
@@ -33,7 +32,6 @@ import (
func NewInMemoryStorage() *gtsstorage.Driver {
storage := storage.OpenMemory(200, false)
return &gtsstorage.Driver{
- KVStore: kv.New(storage),
Storage: storage,
}
}
@@ -95,30 +93,18 @@ func StandardStorageSetup(storage *gtsstorage.Driver, relativePath string) {
}
}
-// StandardStorageTeardown deletes everything in storage so that it's clean for
-// the next test
-// nolint:gocritic // complains about the type switch, but it's the cleanest solution
+// StandardStorageTeardown deletes everything in storage so that it's clean for the next test.
func StandardStorageTeardown(storage *gtsstorage.Driver) {
defer os.RemoveAll(path.Join(os.TempDir(), "gotosocial"))
- // Open a storage iterator
- iter, err := storage.Iterator(context.Background(), nil)
- if err != nil {
- panic(err)
- }
-
var keys []string
- for iter.Next() {
- // Collate all of the storage keys
- keys = append(keys, iter.Key())
- }
-
- // Done with iter
- iter.Release()
+ _ = storage.WalkKeys(context.Background(), func(ctx context.Context, key string) error {
+ keys = append(keys, key)
+ return nil
+ })
for _, key := range keys {
- // Ignore errors, we just want to attempt delete all
_ = storage.Delete(context.Background(), key)
}
}