<commit_before>var request = require('../index')
  , http = require('http')
  , server = require('./server')
  , assert = require('assert')
  ;

var s = http.createServer(function (req, resp) {
  resp.statusCode = 200
  resp.end('')
}).listen(6767, function () {
  // requests without agentOptions should use global agent
  var r = request('http://localhost:6767', function (e, resp, body) {
    assert.deepEqual(r.agent, http.globalAgent);
    assert.equal(Object.keys(r.pool).length, 0);

    // requests with agentOptions should apply agentOptions to new agent in pool
    var r2 = request('http://localhost:6767', { agentOptions: { foo: 'bar' } }, function (e, resp, body) {
      assert.equal(r2.agent.options.foo, 'bar');
      assert.equal(Object.keys(r2.pool).length, 1);
	    s.close()
 	 });
  })
})<commit_msg>Rewrite tests/test-agentOptions.js to use tape<commit_after>var request = require('../index')
  , http    = require('http')
  , server  = require('./server')
  , tape    = require('tape')

var s
  , port = 8111

tape('setup', function(t) {
  s = server.createServer(function (req, resp) {
    resp.statusCode = 200
    resp.end('')
  }).listen(port, function() {
    t.end()
  })
})

tape('without agentOptions should use global agent', function(t) {
  t.plan(3)
  var r = request(s.url, function(err, res, body) {
    t.equal(err, null)
    t.deepEqual(r.agent, http.globalAgent)
    t.equal(Object.keys(r.pool).length, 0)
  })
})

tape('with agentOptions should apply to new agent in pool', function(t) {
  t.plan(3)
  var r = request(s.url, {
    agentOptions: { foo: 'bar' }
  }, function(err, res, body) {
    t.equal(err, null)
    t.equal(r.agent.options.foo, 'bar')
    t.equal(Object.keys(r.pool).length, 1)
  })
})

tape('cleanup', function(t) {
  s.close()
  t.end()
})
{'fraction_non_alphanumeric': 0.1804553026096613, 'fraction_numerical': 0.017212659633536923, 'mean_word_length': 3.4166666666666665, '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': '6481716', 'n_tokens_mistral': 653, 'n_tokens_neox': 628, 'n_words': 142}