Add a test to complete code coverage.

FossilOrigin-Name: c8ac76905df042f626c4a2a4bac2512f489b520150b12d661ecf9d8fdb10e248
This commit is contained in:
Mahlon E. Smith 2022-12-22 01:40:27 +00:00
parent 07ab25d126
commit cfc0b7c301

View file

@ -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' }