aboutsummaryrefslogtreecommitdiff
path: root/rwtransaction_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'rwtransaction_test.go')
-rw-r--r--rwtransaction_test.go48
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")
+}