diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-16 12:36:37 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-16 12:36:37 -0700 |
commit | 63e8e474d7d26f60eb6f97f92f051a925958819f (patch) | |
tree | 3d52bf8fe4b404cc925a2c2b57e810382252e4fd /rwtransaction_test.go | |
parent | Merge branch 'master' of https://github.com/boltdb/bolt (diff) | |
download | dedo-63e8e474d7d26f60eb6f97f92f051a925958819f.tar.gz dedo-63e8e474d7d26f60eb6f97f92f051a925958819f.tar.xz |
Add CreateBucketIfNotExists().
Diffstat (limited to 'rwtransaction_test.go')
-rw-r--r-- | rwtransaction_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/rwtransaction_test.go b/rwtransaction_test.go index 704c563..ea84b87 100644 --- a/rwtransaction_test.go +++ b/rwtransaction_test.go @@ -44,6 +44,19 @@ func TestRWTransactionCreateBucket(t *testing.T) { }) } +// Ensure that a bucket can be created if it doesn't already exist. +func TestRWTransactionCreateBucketIfNotExists(t *testing.T) { + withOpenDB(func(db *DB, path string) { + assert.NoError(t, db.CreateBucketIfNotExists("widgets")) + assert.NoError(t, db.CreateBucketIfNotExists("widgets")) + + // Read the bucket through a separate transaction. + b, err := db.Bucket("widgets") + assert.NotNil(t, b) + assert.NoError(t, err) + }) +} + // Ensure that a bucket cannot be created twice. func TestRWTransactionRecreateBucket(t *testing.T) { withOpenDB(func(db *DB, path string) { |