diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-15 14:54:45 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-15 14:54:45 -0700 |
commit | 56b825fb56a29da6e460475fcd5a98feb795f194 (patch) | |
tree | 5ea69a648a4fb259e8f8b9c855fc7eba7e276894 /db_test.go | |
parent | Merge pull request #31 from benbjohnson/sequence (diff) | |
download | dedo-56b825fb56a29da6e460475fcd5a98feb795f194.tar.gz dedo-56b825fb56a29da6e460475fcd5a98feb795f194.tar.xz |
Add transactional blocks.
Diffstat (limited to 'db_test.go')
-rw-r--r-- | db_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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) |