aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/test/cases/adapters/mysql/statement_pool_test.rb
blob: 83de90f179a6ad48cdd35ecd8d12c94bcb05c968 (plain) (tree)






















                                                                          
require 'cases/helper'

module ActiveRecord::ConnectionAdapters
  class MysqlAdapter
    class StatementPoolTest < ActiveRecord::TestCase
      def test_cache_is_per_pid
        return skip('must support fork') unless Process.respond_to?(:fork)

        cache = StatementPool.new nil, 10
        cache['foo'] = 'bar'
        assert_equal 'bar', cache['foo']

        pid = fork {
          lookup = cache['foo'];
          exit!(!lookup)
        }

        Process.waitpid pid
        assert $?.success?, 'process should exit successfully'
      end
    end
  end
end