test/test_transactions.rb in swift-0.7.2 vs test/test_transactions.rb in swift-0.8.0
- old
+ new
@@ -1,16 +1,19 @@
require_relative 'helper'
describe 'Adapter' do
- supported_by Swift::DB::Postgres, Swift::DB::Mysql, Swift::DB::DB2 do
+ supported_by Swift::DB::Postgres, Swift::DB::Mysql, Swift::DB::Sqlite3 do
describe 'transactions' do
before do
@name = 'test1 - transaction 1'
@db = Swift.db
- @db.execute %q{drop table users} rescue nil
- @db.execute %q{create table users(name varchar(512), created_at timestamp)}
- @db.execute %q{alter table users engine=innodb} if @db.kind_of?(Swift::DB::Mysql) # In case of MyISAM default.
+ @db.execute %q{drop table if exists users}
+ @db.execute %q{create table users(name text, created_at timestamp)}
+
+ # In case of MyISAM default.
+ @db.kind_of?(Swift::DB::Mysql) && @db.execute('alter table users engine=innodb')
+
@sth = @db.prepare('select count(*) as c from users where name = ?')
end
it 'yields db to block' do
@db.transaction do |db|
@@ -22,11 +25,11 @@
end
end
describe 'commits work' do
before do
- @db.execute('truncate users')
+ @db.execute('delete from users')
end
after do
assert_equal 1, @sth.execute(@name).first[:c]
end
@@ -45,11 +48,11 @@
end
end # commits work
describe 'rollbacks work' do
before do
- @db.execute('truncate users')
+ @db.execute('delete from users')
end
after do
assert_equal 0, @sth.execute(@name).first[:c]
end
@@ -71,10 +74,10 @@
end
end # rollbacks work
describe 'nested transactions' do
before do
- @db.execute('truncate users')
+ @db.execute('delete from users')
end
after do
assert_equal 1, @sth.execute(@name).first[:c]
end