diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-03-23 11:52:10 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-03-23 11:52:10 -0600 |
commit | 8303617b72cc0caf4cf7b70a8470c32a389186be (patch) | |
tree | 96a0dbb8820c3eec1a596363875d75f80acd68ca /db_test.go | |
parent | Merge pull request #76 from benbjohnson/fsync (diff) | |
parent | Mark Do()/With() transaction as managed. (diff) | |
download | dedo-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.go | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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) { |