2014-07-28 05:25:40 +04:00
|
|
|
package store
|
|
|
|
|
|
|
|
import (
|
2014-08-07 12:49:48 +04:00
|
|
|
"github.com/siddontang/ledisdb/config"
|
2014-07-28 05:25:40 +04:00
|
|
|
"os"
|
2014-08-07 12:49:48 +04:00
|
|
|
|
2014-07-28 05:25:40 +04:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newTestLMDB() *DB {
|
2014-08-07 12:49:48 +04:00
|
|
|
cfg := new(config.Config)
|
|
|
|
cfg.DBName = "lmdb"
|
|
|
|
cfg.DataDir = "/tmp/testdb"
|
|
|
|
cfg.LMDB.MapSize = 10 * 1024 * 1024
|
2014-07-28 05:25:40 +04:00
|
|
|
|
2014-08-07 12:49:48 +04:00
|
|
|
os.RemoveAll(getStorePath(cfg))
|
2014-07-28 05:25:40 +04:00
|
|
|
|
|
|
|
db, err := Open(cfg)
|
|
|
|
if err != nil {
|
|
|
|
println(err.Error())
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return db
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLMDB(t *testing.T) {
|
|
|
|
db := newTestLMDB()
|
|
|
|
|
|
|
|
testStore(db, t)
|
|
|
|
|
|
|
|
db.Close()
|
|
|
|
}
|
2014-07-29 13:29:51 +04:00
|
|
|
|
|
|
|
func TestLMDBTx(t *testing.T) {
|
|
|
|
db := newTestLMDB()
|
|
|
|
|
|
|
|
testTx(db, t)
|
|
|
|
|
|
|
|
db.Close()
|
|
|
|
}
|