diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-26 16:37:22 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-26 16:37:22 -0700 |
commit | 0209ad2ed4d215462f5b91958da495be89eff2c0 (patch) | |
tree | b14c3f9b43c91608a85282ab11c013600633a16c /db_test.go | |
parent | Remove RWTransaction.Bucket(). (diff) | |
parent | Add bolt.Open(). (diff) | |
download | dedo-0209ad2ed4d215462f5b91958da495be89eff2c0.tar.gz dedo-0209ad2ed4d215462f5b91958da495be89eff2c0.tar.xz |
Merge pull request #53 from benbjohnson/open-api
Add bolt.Open()
Diffstat (limited to 'db_test.go')
-rw-r--r-- | db_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -15,6 +15,27 @@ import ( ) // Ensure that a database can be opened without error. +func TestOpen(t *testing.T) { + f, _ := ioutil.TempFile("", "bolt-") + path := f.Name() + f.Close() + os.Remove(path) + defer os.RemoveAll(path) + + db, err := Open(path, 0666) + assert.NoError(t, err) + assert.NotNil(t, db) + db.Close() +} + +// Ensure that opening a database with a bad path returns an error. +func TestOpenBadPath(t *testing.T) { + db, err := Open("/../bad-path", 0666) + assert.Error(t, err) + assert.Nil(t, db) +} + +// Ensure that a database can be opened without error. func TestDBOpen(t *testing.T) { withDB(func(db *DB, path string) { err := db.Open(path, 0666) |