storj/storage/testsuite/test.go

38 lines
1.0 KiB
Go
Raw Normal View History

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package testsuite
import (
"testing"
"storj.io/storj/storage"
)
// RunTests runs common storage.KeyValueStore tests
func RunTests(t *testing.T, store storage.KeyValueStore) {
// store = storelogger.NewTest(t, store)
t.Run("CRUD", func(t *testing.T) { testCRUD(t, store) })
t.Run("Constraints", func(t *testing.T) { testConstraints(t, store) })
t.Run("Iterate", func(t *testing.T) { testIterate(t, store) })
t.Run("IterateAll", func(t *testing.T) { testIterateAll(t, store) })
t.Run("Prefix", func(t *testing.T) { testPrefix(t, store) })
t.Run("List", func(t *testing.T) { testList(t, store) })
t.Run("ListV2", func(t *testing.T) { testListV2(t, store) })
}
func testConstraints(t *testing.T, store storage.KeyValueStore) {
t.Run("Put Empty", func(t *testing.T) {
var key storage.Key
var val storage.Value
defer func() { _ = store.Delete(key) }()
err := store.Put(key, val)
if err == nil {
t.Fatal("putting empty key should fail")
}
})
}