aboutsummaryrefslogtreecommitdiff
path: root/db_test.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-02-15 15:01:02 -0700
committerBen Johnson <benbjohnson@yahoo.com>2014-02-15 15:01:02 -0700
commit2b5e4403161acec06c169ce286b2761ee96a2ce1 (patch)
tree5ea69a648a4fb259e8f8b9c855fc7eba7e276894 /db_test.go
parentMerge pull request #31 from benbjohnson/sequence (diff)
parentAdd transactional blocks. (diff)
downloaddedo-2b5e4403161acec06c169ce286b2761ee96a2ce1.tar.gz
dedo-2b5e4403161acec06c169ce286b2761ee96a2ce1.tar.xz
Merge pull request #32 from benbjohnson/blocks
Transactional Blocks
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)