<commit_before>var assert = require('assert'),
  uuid = require('node-uuid');

describe('config', function() {

  beforeEach(function() {
    this.oldHost = process.env.HOSTNAME;
    this.oldUsr = process.env.USER;
  });

  afterEach(function() {
    process.env.HOSTNAME = this.oldHost;
    process.env.USER = this.oldUsr;
    process.env.LOCAL_QUEUE = '';
    process.env.AMQP_URL = '';
    process.env.AMQP_DEBUG = '';
  });

  describe('retrocompat', function() {

    var retrocompat = require('../src/modules/retrocompat-config');

    it('should set config as empty array if no config present', function() {
      let conf = retrocompat();
      assert.deepEqual(conf, {});
    });

    it('should be able to override default config options based on config object', function() {
      let conf = {
        amqpUrl: 'ok',
        amqpPrefetch: 1,
        amqpRequeue: true,
        amqpTimeout: 5
      };

      conf = retrocompat(conf);

      assert.equal(conf.host, conf.amqpUrl);
      assert.equal(conf.prefetch, conf.amqpPrefetch);
      assert.equal(conf.requeue, conf.amqpRequeue);
      assert.equal(conf.timeout, conf.amqpTimeout);
    });

    it('should be able to override default config options based on env vars', function() {
      process.env.LOCAL_QUEUE = ':test';
      process.env.AMQP_URL = 'ok';
      process.env.AMQP_DEBUG = true;

      let conf = retrocompat();

      //ensure transport is console
      assert(conf.transport.assert);
      assert.equal(conf.host, process.env.AMQP_URL);
      assert.equal(conf.consumerSuffix, process.env.LOCAL_QUEUE);
    });
  });

  describe('entry point', function() {
    var main = require('../src/index');

    it('should be able to merge config', function() {
      var conf = { host: 'amqp://my-host' };
      assert.equal(main(conf).producer.conn.config.host, 'amqp://my-host');
    });

    it('should generate an uuid as hostname if no env for HOSTNAME/USER', function() {<commit_msg>Switched off listeners limit for tests resolves #40<commit_after>var assert = require('assert'),
  uuid = require('node-uuid');

require('events').EventEmitter.prototype._maxListeners = 100;

describe('config', function() {

  beforeEach(function() {
    this.oldHost = process.env.HOSTNAME;
    this.oldUsr = process.env.USER;
  });

  afterEach(function() {
    process.env.HOSTNAME = this.oldHost;
    process.env.USER = this.oldUsr;
    process.env.LOCAL_QUEUE = '';
    process.env.AMQP_URL = '';
    process.env.AMQP_DEBUG = '';
  });

  describe('retrocompat', function() {

    var retrocompat = require('../src/modules/retrocompat-config');

    it('should set config as empty array if no config present', function() {
      let conf = retrocompat();
      assert.deepEqual(conf, {});
    });

    it('should be able to override default config options based on config object', function() {
      let conf = {
        amqpUrl: 'ok',
        amqpPrefetch: 1,
        amqpRequeue: true,
        amqpTimeout: 5
      };

      conf = retrocompat(conf);

      assert.equal(conf.host, conf.amqpUrl);
      assert.equal(conf.prefetch, conf.amqpPrefetch);
      assert.equal(conf.requeue, conf.amqpRequeue);
      assert.equal(conf.timeout, conf.amqpTimeout);
    });

    it('should be able to override default config options based on env vars', function() {
      process.env.LOCAL_QUEUE = ':test';
      process.env.AMQP_URL = 'ok';
      process.env.AMQP_DEBUG = true;

      let conf = retrocompat();

      //ensure transport is console
      assert(conf.transport);
      assert.equal(conf.host, process.env.AMQP_URL);
      assert.equal(conf.consumerSuffix, process.env.LOCAL_QUEUE);
    });
  });

  describe('entry point', function() {
    var main = require('../src/index');

    it('should be able to merge config', function() {
      var conf = { host: 'amqp://my-host' };
      assert.equal(main(conf).producer.conn.config.host, 'amqp://my-host');
    });

    it('should generate an uuid as hostname if no env for HOSTNAME/USER', function() {
{'fraction_non_alphanumeric': 0.1463717693836978, 'fraction_numerical': 0.0022365805168986083, 'mean_word_length': 2.977272727272727, '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': '7107965', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1228, 'n_words': 279}