aboutsummaryrefslogtreecommitdiff
path: root/db_test.go
diff options
context:
space:
mode:
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) {