forked from tendermint/tm-db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rocksdb_test.go
47 lines (36 loc) · 920 Bytes
/
rocksdb_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//go:build rocksdb
// +build rocksdb
package db
import (
"fmt"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestRocksDBBackend(t *testing.T) {
name := fmt.Sprintf("test_%x", randStr(12))
dir := os.TempDir()
db, err := NewDB(name, RocksDBBackend, dir)
require.NoError(t, err)
defer cleanupDBDir(dir, name)
_, ok := db.(*RocksDB)
assert.True(t, ok)
}
func TestWithRocksDB(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "rocksdb")
db, err := NewRocksDB(path, "")
require.NoError(t, err)
t.Run("RocksDB", func(t *testing.T) { Run(t, db) })
}
func TestRocksDBStats(t *testing.T) {
name := fmt.Sprintf("test_%x", randStr(12))
dir := os.TempDir()
db, err := NewDB(name, RocksDBBackend, dir)
require.NoError(t, err)
defer cleanupDBDir(dir, name)
assert.NotEmpty(t, db.Stats())
}
// TODO: Add tests for rocksdb