spec/adapters/sqlite_spec.rb in sequel-3.40.0 vs spec/adapters/sqlite_spec.rb in sequel-3.41.0

- old
+ new

@@ -593,6 +593,39 @@ @db.add_index :a, :b @db.add_index :a, [:b, :a] @db.drop_column :a, :b @db.indexes(:a).should == {:a_a_index=>{:unique=>false, :columns=>[:a]}} end -end + + specify "should have support for various #transaction modes" do + sqls = [] + @db.loggers << (l=Class.new{%w'info error'.each{|m| define_method(m){|sql| sqls << sql}}}.new) + + @db.transaction(:mode => :immediate) do + sqls.last.should == "BEGIN IMMEDIATE TRANSACTION" + end + @db.transaction(:mode => :exclusive) do + sqls.last.should == "BEGIN EXCLUSIVE TRANSACTION" + end + @db.transaction(:mode => :deferred) do + sqls.last.should == "BEGIN DEFERRED TRANSACTION" + end + @db.transaction do + sqls.last.should == Sequel::Database::SQL_BEGIN + end + + @db.transaction_mode.should == nil + @db.transaction_mode = :immediate + @db.transaction_mode.should == :immediate + @db.transaction do + sqls.last.should == "BEGIN IMMEDIATE TRANSACTION" + end + @db.transaction(:mode => :exclusive) do + sqls.last.should == "BEGIN EXCLUSIVE TRANSACTION" + end + + proc {@db.transaction_mode = :invalid}.should raise_error(Sequel::Error) + + @db.transaction_mode.should == :immediate + proc {@db.transaction(:mode => :invalid) {}}.should raise_error(Sequel::Error) + end +end