mirror of https://github.com/etcd-io/bbolt.git
28 lines
402 B
Go
28 lines
402 B
Go
package bolt
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestDBOpen(t *testing.T) {
|
|
withDB(func(db *DB, path string) {
|
|
err := db.Open(path, 0666)
|
|
assert.NoError(t, err)
|
|
})
|
|
}
|
|
|
|
func withDB(fn func(*DB, string)) {
|
|
f, _ := ioutil.TempFile("", "bolt-")
|
|
path := f.Name()
|
|
f.Close()
|
|
os.Remove(path)
|
|
defer os.RemoveAll(path)
|
|
|
|
db := NewDB()
|
|
fn(db, path)
|
|
}
|