mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Close a transaction when return
ing from within its block (#167)
This commit is contained in:
parent
167b55966e
commit
e076a08cd0
2 changed files with 31 additions and 10 deletions
|
@ -95,6 +95,20 @@ describe DB::Transaction do
|
|||
t.committed.should be_false
|
||||
end
|
||||
|
||||
it "transaction with block from connection should be committed if `return` is called" do
|
||||
t = uninitialized DummyDriver::DummyTransaction
|
||||
|
||||
with_witness do |w|
|
||||
with_dummy_connection do |cnn|
|
||||
t = return_from_txn(cnn).as(DummyDriver::DummyTransaction)
|
||||
w.check
|
||||
end
|
||||
end
|
||||
|
||||
t.rolledback.should be_false
|
||||
t.committed.should be_true
|
||||
end
|
||||
|
||||
it "transaction can be committed within block" do
|
||||
with_dummy_connection do |cnn|
|
||||
cnn.transaction do |tx|
|
||||
|
@ -211,3 +225,9 @@ describe DB::Transaction do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
private def return_from_txn(cnn)
|
||||
cnn.transaction do |tx|
|
||||
return tx
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue