<commit_before>require 'spec_helper'
require 'em-synchrony'
require 'em-synchrony/fiber_iterator'

describe EM::PG::Sequel do
  DELAY = 1
  QUERY = "select pg_sleep(#{DELAY})"

  let(:url) { DB_URL }
  let(:size) { 1 }
  let(:db) { Sequel.connect(url, max_connection: size, pool_class: :em_synchrony, db_logger: Logger.new(nil)) }
  let(:test) { db[:test] }

  describe "unexist table" do
    it "should raise exception" do
      EM.synchrony do
        proc { test.all }.must_raise Sequel::DatabaseError

        EM.stop
      end
    end
  end

  describe "exist table" do

    before do
      EM.synchrony do
        db.create_table!(:test) do
          text :name
          integer :value, index: true
        end

        EM.stop
      end
    end

    after do
      EM.synchrony do
        db.drop_table?(:test)<commit_msg>fix specs max_connection[s] option + sanity check<commit_after>require 'spec_helper'
require 'em-synchrony'
require 'em-synchrony/fiber_iterator'

describe EM::PG::Sequel do
  DELAY = 1
  QUERY = "select pg_sleep(#{DELAY})"

  let(:url) { DB_URL }
  let(:size) { 1 }
  let(:db) { Sequel.connect(url, max_connections: size, pool_class: :em_synchrony, db_logger: Logger.new(nil)) }
  let(:test) { db[:test] }

  describe "sanity" do
    let(:size) { 42 }

    it "should have max_size 42" do
      db.pool.pool.max_size.must_equal 42
    end
  end

  describe "unexist table" do
    it "should raise exception" do
      EM.synchrony do
        proc { test.all }.must_raise Sequel::DatabaseError

        EM.stop
      end
    end
  end

  describe "exist table" do

    before do
      EM.synchrony do
        db.create_table!(:test) do
          text :name
          integer :value, index: true
        end

        EM.stop
      end
    end

    after do
      EM.synchrony do
        db.drop_table?(:test)
{'fraction_non_alphanumeric': 0.10893246187363835, 'fraction_numerical': 0.0054466230936819175, 'mean_word_length': 2.4530075187969924, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5303035', 'n_tokens_mistral': 664, 'n_tokens_neox': 627, 'n_words': 163}