diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-01-30 00:11:46 -0500 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-01-30 00:11:46 -0500 |
commit | 149d48fb9e3e8147cf0bce84a4e11164ac9cdbf3 (patch) | |
tree | 2616c762651a8e516e348c3741d502a1f68ffd16 /rwtransaction_test.go | |
parent | Add freelist page type. (diff) | |
download | dedo-149d48fb9e3e8147cf0bce84a4e11164ac9cdbf3.tar.gz dedo-149d48fb9e3e8147cf0bce84a4e11164ac9cdbf3.tar.xz |
Fix leaf/branch deserialization.
Diffstat (limited to 'rwtransaction_test.go')
-rw-r--r-- | rwtransaction_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/rwtransaction_test.go b/rwtransaction_test.go new file mode 100644 index 0000000..19952e8 --- /dev/null +++ b/rwtransaction_test.go @@ -0,0 +1,48 @@ +package bolt + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// Ensure that a RWTransaction can be retrieved. +func TestRWTransaction(t *testing.T) { + withOpenDB(func(db *DB, path string) { + txn, err := db.RWTransaction() + assert.NotNil(t, txn) + assert.NoError(t, err) + }) +} + +// Ensure that a bucket can be created and retrieved. +func TestTransactionCreateBucket(t *testing.T) { + withOpenDB(func(db *DB, path string) { + // Create a bucket. + txn, _ := db.RWTransaction() + err := txn.CreateBucket("widgets") + assert.NoError(t, err) + + // Commit the transaction. + err = txn.Commit() + assert.NoError(t, err) + + /* + // Open a separate read-only transaction. + rtxn, err := db.Transaction() + assert.NotNil(t, txn) + assert.NoError(t, err) + + b, err := rtxn.Bucket("widgets") + assert.NoError(t, err) + if assert.NotNil(t, b) { + assert.Equal(t, b.Name(), "widgets") + } + */ + }) +} + +// Ensure that an existing bucket cannot be created. +func TestTransactionCreateExistingBucket(t *testing.T) { + t.Skip("pending") +} |