Sha256: ba1b18e3bd942bd2f918b64340a40276a2873f9ff788280d749675468027be1d

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require_relative 'helper'
require 'swift/pool'

describe 'Adapter' do
  supported_by Swift::DB::Postgres, Swift::DB::Mysql do
    describe 'Asynchronous connection pool' do
      before do
        Swift.db do |db|
          db.execute %q{drop table if exists users}
          db.execute %Q{create table users(id serial, name text)}
        end
      end

      it 'creates connection pool' do
        driver = Swift.db.kind_of?(Swift::DB::Mysql) ? 'mysql' : 'postgresql'
        assert Swift::Pool.new 5, db: 'swift_test', driver: driver
      end

      describe 'Running queries' do
        it 'should select data' do
          rows = []
          assert Swift.db.write('users', %w{name}, StringIO.new("user1\nuser2\nuser3\n"))
          Swift.pool 5 do |pool|
            pool.execute('select * from users') do |rs|
              rows += rs.to_a
              pool.execute('select * from users') {|rs| rows += rs.to_a }
            end
          end
          assert_equal 6, rows.length
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
swift-0.6.1 test/test_pool.rb
swift-0.6.0 test/test_pool.rb
swift-0.5.1 test/test_pool.rb
swift-0.5.0 test/test_pool.rb