From cfc0b7c30132b043e0730e548b8be5814d8d54d1 Mon Sep 17 00:00:00 2001 From: mahlon Date: Thu, 22 Dec 2022 01:40:27 +0000 Subject: [PATCH] Add a test to complete code coverage. FossilOrigin-Name: c8ac76905df042f626c4a2a4bac2512f489b520150b12d661ecf9d8fdb10e248 --- spec/mdbx/database_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/mdbx/database_spec.rb b/spec/mdbx/database_spec.rb index 1129942..3af2396 100644 --- a/spec/mdbx/database_spec.rb +++ b/spec/mdbx/database_spec.rb @@ -236,6 +236,15 @@ RSpec.describe( MDBX::Database ) do expect( db.collection ).to eq( 'bucket' ) end + it "ensures transactions have closed if deserialization fails" do + db.deserializer = ->( v ) { raise "ka-bloooey!" } + db['foo'] = 1 + expect { + db.transaction { db['foo'] } + }.to raise_error( RuntimeError, /ka-bloooey!/ ) + expect( db.in_transaction? ).to be_falsey + end + it "revert back to the previous collection when used in a block" do expect( db.collection ).to be_nil db.collection( 'bucket' ) { 'no-op' }