<commit_before>require 'helper'

class TestCurbThreadpool < MiniTest::Unit::TestCase

  def setup
    WebMock.reset!
  end

  def test_get
    i = 0
    stub = stub_request(:get, "http://www.google.com/").
      to_return {
        i += 1
        { :status => 200, :body => "res #{i}" }
      }

    url = "http://www.google.com"
    pool = Curl::ThreadPool.new
    ret = pool.get(url)

    assert ret
    assert_equal 1, ret.size
    assert_equal "res 1", ret.first

    ret = pool.get([url])

    assert ret
    assert_equal 1, ret.size
    assert_equal "res 2", ret.first


    pool.reset()

    i = 0
    urls = [url, url, url]
    ret = pool.get(urls)
    assert ret
    assert_equal 3, ret.size
    ret.each_with_index do |r, idx|
      assert_equal "res #{idx+1}", r
    end
  end

  def test_get_nil
    pool = Curl::ThreadPool.new
    ret = pool.get([])
    assert_kind_of Array, ret
    assert_empty ret
  end

end<commit_msg>refactor tests<commit_after>require 'helper'

class TestCurbThreadpool < MiniTest::Unit::TestCase

  def setup
    super
    WebMock.reset!
    @url = "http://www.google.com"
    @pool = Curl::ThreadPool.new
    @i = 0
  end

  def teardown
    super
    @pool.reset()
  end

  def test_get
    stub_get()
    ret = @pool.get(@url)

    assert ret
    assert_equal 1, ret.size
    assert_equal "res 1", ret.first
  end

  def test_get_array_param
    stub_get()
    ret = @pool.get([@url])

    assert ret
    assert_equal 1, ret.size
    assert_equal "res 1", ret.first
  end

  def test_get_multiple
    stub_get()
    urls = [@url, @url, @url]
    ret = @pool.get(urls)
    assert ret
    assert_equal 3, ret.size
    ret.each_with_index do |r, idx|
      assert_equal "res #{idx+1}", r
    end
  end

  def test_get_nil
    pool = Curl::ThreadPool.new
    ret = pool.get([])
    assert_kind_of Array, ret
    assert_empty ret
  end


  private

  def stub_get
    stub = stub_request(:get, "http://www.google.com/").
      to_return {
        @i += 1
        { :status => 200, :body => "res #{@i}" }
      }
  end



end
{'fraction_non_alphanumeric': 0.12184466019417475, 'fraction_numerical': 0.01116504854368932, 'mean_word_length': 2.281847133757962, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '4598979', 'n_tokens_mistral': 784, 'n_tokens_neox': 745, 'n_words': 190}