diff options
Diffstat (limited to 'transaction_test.go')
-rw-r--r-- | transaction_test.go | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/transaction_test.go b/transaction_test.go index 6365368..084ef6d 100644 --- a/transaction_test.go +++ b/transaction_test.go @@ -9,31 +9,20 @@ import ( // Ensure that a bucket can be created and retrieved. func TestTransactionCreateBucket(t *testing.T) { withOpenDB(func(db *DB, path string) { - txn, _ := db.Transaction(false) - b, err := txn.CreateBucket("foo", false) - if assert.NoError(t, err) && assert.NotNil(t, b) { - b2, err := txn.Bucket("foo") - assert.NoError(t, err) - assert.Equal(t, b, b2) + txn, _ := db.RWTransaction() + err := txn.CreateBucket("foo") + if assert.NoError(t, err) { + assert.NotNil(t, txn.Bucket("foo")) } }) } -// Ensure that a user-created transaction cannot be used to create a bucket. -func TestTransactionInvalidCreateBucket(t *testing.T) { - withOpenDB(func(db *DB, path string) { - txn := new(Transaction) - _, err := txn.CreateBucket("foo", false) - assert.Equal(t, err, InvalidTransactionError) - }) -} - // Ensure that an existing bucket cannot be created. func TestTransactionCreateExistingBucket(t *testing.T) { withOpenDB(func(db *DB, path string) { - txn, _ := db.Transaction(false) - txn.CreateBucket("foo", false) - _, err := txn.CreateBucket("foo", false) + txn, _ := db.RWTransaction() + txn.CreateBucket("foo") + err := txn.CreateBucket("foo") assert.Equal(t, err, BucketAlreadyExistsError) }) } |