<commit_before>require File.expand_path("../helper.rb", __FILE__)

context "DatabaseTest" do

  setup do
    @database = init_db
  end

  teardown do
    @database.disconnect
  end

  test "drain_notify clears all of the notifications" do
    @database.listen
    @database.execute("NOTIFY queue_classic_jobs, 'hello'")

    assert ! @database.connection.notifies.nil?
    assert   @database.connection.notifies.nil?

    @database.execute("NOTIFY queue_classic_jobs, 'hello'")
    @database.execute("NOTIFY queue_classic_jobs, 'hello'")
    @database.execute("NOTIFY queue_classic_jobs, 'hello'")

    @database.drain_notify
    assert   @database.connection.notifies.nil?
  end

end<commit_msg>Add basic test for Database#execute.<commit_after>require File.expand_path("../helper.rb", __FILE__)

context "DatabaseTest" do

  setup do
    @database = init_db
  end

  teardown do
    @database.disconnect
  end

  test "drain_notify clears all of the notifications" do
    @database.listen
    @database.execute("NOTIFY queue_classic_jobs, 'hello'")

    assert ! @database.connection.notifies.nil?
    assert   @database.connection.notifies.nil?

    @database.execute("NOTIFY queue_classic_jobs, 'hello'")
    @database.execute("NOTIFY queue_classic_jobs, 'hello'")
    @database.execute("NOTIFY queue_classic_jobs, 'hello'")

    @database.drain_notify
    assert   @database.connection.notifies.nil?
  end

  test "execute should return rows" do
    result = @database.execute 'SELECT 11 foo, 22 bar;'
    assert_equal [{'foo'=>'11', 'bar'=>'22'}], result.to_a
  end

end
{'fraction_non_alphanumeric': 0.116751269035533, 'fraction_numerical': 0.005076142131979695, 'mean_word_length': 4.087096774193548, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4401831', 'n_tokens_mistral': 530, 'n_tokens_neox': 502, 'n_words': 111}