Browse Source

Export DbBackendType in order to fix IAVL tests

pull/1842/head
Adrian Brink 7 years ago
parent
commit
cbc63518e5
No known key found for this signature in database GPG Key ID: F61053D3FBD06353
3 changed files with 11 additions and 11 deletions
  1. +1
    -1
      db/backend_test.go
  2. +1
    -1
      db/common_test.go
  3. +9
    -9
      db/db.go

+ 1
- 1
db/backend_test.go View File

@ -15,7 +15,7 @@ func cleanupDBDir(dir, name string) {
os.RemoveAll(filepath.Join(dir, name) + ".db")
}
func testBackendGetSetDelete(t *testing.T, backend dbBackendType) {
func testBackendGetSetDelete(t *testing.T, backend DbBackendType) {
// Default
dir, dirname := cmn.Tempdir(fmt.Sprintf("test_backend_%s_", backend))
defer dir.Close()


+ 1
- 1
db/common_test.go View File

@ -45,7 +45,7 @@ func checkValuePanics(t *testing.T, itr Iterator) {
assert.Panics(t, func() { itr.Key() }, "checkValuePanics expected panic but didn't")
}
func newTempDB(t *testing.T, backend dbBackendType) (db DB) {
func newTempDB(t *testing.T, backend DbBackendType) (db DB) {
dir, dirname := cmn.Tempdir("test_go_iterator")
db = NewDB("testdb", backend, dirname)
dir.Close()


+ 9
- 9
db/db.go View File

@ -5,21 +5,21 @@ import "fmt"
//----------------------------------------
// Main entry
type dbBackendType string
type DbBackendType string
const (
LevelDBBackend dbBackendType = "leveldb" // legacy, defaults to goleveldb unless +gcc
CLevelDBBackend dbBackendType = "cleveldb"
GoLevelDBBackend dbBackendType = "goleveldb"
MemDBBackend dbBackendType = "memdb"
FSDBBackend dbBackendType = "fsdb" // using the filesystem naively
LevelDBBackend DbBackendType = "leveldb" // legacy, defaults to goleveldb unless +gcc
CLevelDBBackend DbBackendType = "cleveldb"
GoLevelDBBackend DbBackendType = "goleveldb"
MemDBBackend DbBackendType = "memdb"
FSDBBackend DbBackendType = "fsdb" // using the filesystem naively
)
type dbCreator func(name string, dir string) (DB, error)
var backends = map[dbBackendType]dbCreator{}
var backends = map[DbBackendType]dbCreator{}
func registerDBCreator(backend dbBackendType, creator dbCreator, force bool) {
func registerDBCreator(backend DbBackendType, creator dbCreator, force bool) {
_, ok := backends[backend]
if !force && ok {
return
@ -27,7 +27,7 @@ func registerDBCreator(backend dbBackendType, creator dbCreator, force bool) {
backends[backend] = creator
}
func NewDB(name string, backend dbBackendType, dir string) DB {
func NewDB(name string, backend DbBackendType, dir string) DB {
db, err := backends[backend](name, dir)
if err != nil {
panic(fmt.Sprintf("Error initializing DB: %v", err))


Loading…
Cancel
Save