forked from sitanshunanda/shield
-
Notifications
You must be signed in to change notification settings - Fork 1
/
leveldb_test.go
46 lines (39 loc) · 877 Bytes
/
leveldb_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
package shield
import (
"testing"
)
func TestLevelDB(t *testing.T) {
store := NewLevelDBStore("./db")
store.Reset()
defer store.Close()
db, err := store.(*LevelDBStore).conn()
if err != nil {
t.Fatal(err)
}
err = db.Put([]byte("test-value"), []byte("2024"), nil)
if err != nil {
t.Fatal(err)
}
val, err := db.Get([]byte("test-value"), nil)
if err != nil {
t.Fatal(err)
}
if string(val) != "2024" {
t.Fatal(val)
}
}
func TestLevelDBLast(t *testing.T) {
store := NewLevelDBStore("./db")
defer store.Close()
db, err := store.(*LevelDBStore).conn()
if err != nil {
t.Fatal(err)
}
val, err := db.Get([]byte("test-value"), nil)
if err != nil {
t.Fatal(err)
}
if string(val) != "2024" {
t.Fatal(val)
}
}