aboutsummaryrefslogtreecommitdiff
path: root/db_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'db_test.go')
-rw-r--r--db_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/db_test.go b/db_test.go
index 2682f55..1a9aa02 100644
--- a/db_test.go
+++ b/db_test.go
@@ -178,6 +178,24 @@ func TestDBDelete(t *testing.T) {
})
}
+// Ensure a database can provide a transactional block.
+func TestDBTransactionBlock(t *testing.T) {
+ withOpenDB(func(db *DB, path string) {
+ err := db.Do(func(txn *RWTransaction) error {
+ txn.CreateBucket("widgets")
+ txn.Put("widgets", []byte("foo"), []byte("bar"))
+ txn.Put("widgets", []byte("baz"), []byte("bat"))
+ txn.Delete("widgets", []byte("foo"))
+ return nil
+ })
+ assert.NoError(t, err)
+ value, _ := db.Get("widgets", []byte("foo"))
+ assert.Nil(t, value)
+ value, _ = db.Get("widgets", []byte("baz"))
+ assert.Equal(t, value, []byte("bat"))
+ })
+}
+
// Ensure that the database can be copied to a writer.
func TestDBCopy(t *testing.T) {
t.Skip("pending") // TODO(benbjohnson)