1
0
镜像自地址 https://github.com/tuna/tunasync.git 已同步 2025-12-06 06:26:46 +00:00

Add badger to db backend

这个提交包含在:
Jiajie Chen
2020-10-17 12:05:47 +08:00
父节点 1f963e21aa
当前提交 932dc69ae8
共有 5 个文件被更改,包括 157 次插入1 次删除

查看文件

@@ -162,7 +162,7 @@ func DBAdapterTest(db dbAdapter) {
return
}
func TestBoltAdapter(t *testing.T) {
func TestDBAdapter(t *testing.T) {
Convey("boltAdapter should work", t, func() {
tmpDir, err := ioutil.TempDir("", "tunasync")
defer os.RemoveAll(tmpDir)
@@ -198,4 +198,22 @@ func TestBoltAdapter(t *testing.T) {
DBAdapterTest(redisDB)
})
Convey("badgerAdapter should work", t, func() {
tmpDir, err := ioutil.TempDir("", "tunasync")
defer os.RemoveAll(tmpDir)
So(err, ShouldBeNil)
dbType, dbFile := "badger", filepath.Join(tmpDir, "badger.db")
badgerDB, err := makeDBAdapter(dbType, dbFile)
So(err, ShouldBeNil)
defer func() {
// close badgerDB
err := badgerDB.Close()
So(err, ShouldBeNil)
}()
DBAdapterTest(badgerDB)
})
}