test/test_adapter.rb in swift-0.4.3 vs test/test_adapter.rb in swift-0.5.0

- old
+ new

@@ -42,10 +42,18 @@ it 'executes multiple times' do sth = @db.prepare(%q{insert into users (name, created_at) values (?, now())}) assert sth.execute('Apple Arthurton') assert sth.execute('Benny Arthurton') end + + it 'has insert_id' do + sql = case @db + when Swift::DB::Postgres then %q{insert into users (name, created_at) values (?, now()) returning id} + when Swift::DB::Mysql then %q{insert into users (name, created_at) values (?, now())} + end + assert_kind_of Numeric, @db.prepare(sql).execute('Connie Arthurton').insert_id + end end describe 'executed prepared statements' do before do @db = Swift.db do |db| @@ -74,34 +82,19 @@ it 'returns hash tuples for enumerable methods' do assert_kind_of Hash, @sth.first end - it 'returns array rows for fetchrow' do - assert_kind_of Array, @sth.fetchrow - end - it 'returns a result set on Adapter#execute{}' do @db.execute('select * from users') {|r| assert_kind_of Hash, r } end it 'returns a result set on Adapter#results' do @db.execute('select * from users') - assert_kind_of Swift::ResultSet, @db.results + assert_kind_of Swift::Result, @db.results end end - describe 'transactions' do - it 'yields db to block' do - Swift.db.transaction do |db| - assert_kind_of Swift::Adapter, db - end - - Swift.db.transaction :sweet do |db| - assert_kind_of Swift::Adapter, db - end - end - end #-- # TODO: Not sure how I feel about the block in write; feels like it's just there to get around the fields in the # argument list. How about write('users', %w{name, email, balance}, data)? describe 'bulk writes!' do