forked from tecbot/gorocksdb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
db_v6_test.go
55 lines (42 loc) · 1.33 KB
/
db_v6_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
48
49
50
51
52
53
54
55
//go:build v6
// +build v6
package gorocksdb
import (
"testing"
"github.com/facebookgo/ensure"
)
func TestDBGetApproximateSizes(t *testing.T) {
db := newTestDB(t, "TestDBGetApproximateSizes", nil)
defer db.Close()
// no ranges
sizes, err := db.GetApproximateSizes(nil)
ensure.Nil(t, err)
ensure.DeepEqual(t, len(sizes), 0)
// range will nil start and limit
sizes, err = db.GetApproximateSizes([]Range{{Start: nil, Limit: nil}})
ensure.Nil(t, err)
ensure.DeepEqual(t, sizes, []uint64{0})
// valid range
sizes, err = db.GetApproximateSizes([]Range{{Start: []byte{0x00}, Limit: []byte{0xFF}}})
ensure.Nil(t, err)
ensure.DeepEqual(t, sizes, []uint64{0})
}
func TestDBGetApproximateSizesCF(t *testing.T) {
db := newTestDB(t, "TestDBGetApproximateSizesCF", nil)
defer db.Close()
o := NewDefaultOptions()
cf, err := db.CreateColumnFamily(o, "other")
ensure.Nil(t, err)
// no ranges
sizes, err := db.GetApproximateSizesCF(cf, nil)
ensure.Nil(t, err)
ensure.DeepEqual(t, len(sizes), 0)
// range will nil start and limit
sizes, err = db.GetApproximateSizesCF(cf, []Range{{Start: nil, Limit: nil}})
ensure.Nil(t, err)
ensure.DeepEqual(t, sizes, []uint64{0})
// valid range
sizes, err = db.GetApproximateSizesCF(cf, []Range{{Start: []byte{0x00}, Limit: []byte{0xFF}}})
ensure.Nil(t, err)
ensure.DeepEqual(t, sizes, []uint64{0})
}