mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-07 11:27:50 +00:00
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package index
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"testing"
|
|
"time"
|
|
|
|
// "io/ioutil"
|
|
// "time"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
func TestStorage(t *testing.T) {
|
|
db := "db"
|
|
slice := 0
|
|
bitmap_id := uint64(1234)
|
|
Convey("KV ", t, func() {
|
|
storage, _ := NewKVStorage("/tmp/", 0, db)
|
|
bm := storage.Fetch(bitmap_id, db, slice)
|
|
SetBit(bm, 0)
|
|
SetBit(bm, 1)
|
|
SetBit(bm, 2)
|
|
storage.Store(int64(bitmap_id), db, slice, bm.(*Bitmap))
|
|
bm2 := storage.Fetch(bitmap_id, db, slice)
|
|
So(BitCount(bm), ShouldEqual, BitCount(bm2))
|
|
So(BitCount(bm), ShouldEqual, bm.Count())
|
|
So(BitCount(bm), ShouldEqual, 3)
|
|
|
|
})
|
|
c, err := net.DialTimeout("tcp", "127.0.0.1:9042", 100*time.Millisecond)
|
|
if err != nil {
|
|
fmt.Println("NO cassandra skipping test")
|
|
} else {
|
|
c.Close()
|
|
Convey("cassandra", t, func() {
|
|
storage := NewCassStorage("127.0.0.1", "hotbox")
|
|
|
|
bm := storage.Fetch(bitmap_id, db, slice)
|
|
SetBit(bm, 0)
|
|
SetBit(bm, 1)
|
|
SetBit(bm, 2)
|
|
storage.Store(int64(bitmap_id), db, slice, bm.(*Bitmap))
|
|
bm2 := storage.Fetch(bitmap_id, db, slice)
|
|
So(BitCount(bm), ShouldEqual, BitCount(bm2))
|
|
So(BitCount(bm), ShouldEqual, bm.Count())
|
|
So(BitCount(bm), ShouldEqual, 3)
|
|
|
|
})
|
|
}
|
|
|
|
}
|