aboutsummaryrefslogtreecommitdiff
path: root/db_test.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-03-23 11:52:10 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-03-23 11:52:10 -0600
commit8303617b72cc0caf4cf7b70a8470c32a389186be (patch)
tree96a0dbb8820c3eec1a596363875d75f80acd68ca /db_test.go
parentMerge pull request #76 from benbjohnson/fsync (diff)
parentMark Do()/With() transaction as managed. (diff)
downloaddedo-8303617b72cc0caf4cf7b70a8470c32a389186be.tar.gz
dedo-8303617b72cc0caf4cf7b70a8470c32a389186be.tar.xz
Merge pull request #78 from benbjohnson/tx-managed
Mark Do()/With() transaction as managed.
Diffstat (limited to 'db_test.go')
-rw-r--r--db_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/db_test.go b/db_test.go
index 04abd75..2882ba8 100644
--- a/db_test.go
+++ b/db_test.go
@@ -111,6 +111,23 @@ func TestDBTxBlockWhileClosed(t *testing.T) {
})
}
+// Ensure a panic occurs while trying to commit a managed transaction.
+func TestDBTxBlockWithManualCommitAndRollback(t *testing.T) {
+ withOpenDB(func(db *DB, path string) {
+ db.Do(func(tx *Tx) error {
+ tx.CreateBucket("widgets")
+ assert.Panics(t, func() { tx.Commit() })
+ assert.Panics(t, func() { tx.Rollback() })
+ return nil
+ })
+ db.With(func(tx *Tx) error {
+ assert.Panics(t, func() { tx.Commit() })
+ assert.Panics(t, func() { tx.Rollback() })
+ return nil
+ })
+ })
+}
+
// Ensure that the database can be copied to a file path.
func TestDBCopyFile(t *testing.T) {
withOpenDB(func(db *DB, path string) {