2014-08-02 11:16:16 +04:00
|
|
|
package store
|
|
|
|
|
|
|
|
import (
|
2014-08-07 12:49:48 +04:00
|
|
|
"github.com/siddontang/ledisdb/config"
|
2014-08-02 11:16:16 +04:00
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newTestBoltDB() *DB {
|
2014-08-07 12:49:48 +04:00
|
|
|
cfg := new(config.Config)
|
|
|
|
cfg.DBName = "boltdb"
|
|
|
|
cfg.DataDir = "/tmp/testdb"
|
2014-08-02 11:16:16 +04:00
|
|
|
|
2014-08-07 12:49:48 +04:00
|
|
|
os.RemoveAll(getStorePath(cfg))
|
2014-08-02 11:16:16 +04:00
|
|
|
|
|
|
|
db, err := Open(cfg)
|
|
|
|
if err != nil {
|
|
|
|
println(err.Error())
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return db
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBoltDB(t *testing.T) {
|
|
|
|
db := newTestBoltDB()
|
|
|
|
|
|
|
|
testStore(db, t)
|
|
|
|
|
|
|
|
db.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBoltDBTx(t *testing.T) {
|
|
|
|
db := newTestBoltDB()
|
|
|
|
|
|
|
|
testTx(db, t)
|
|
|
|
|
|
|
|
db.Close()
|
|
|
|
}
|