<commit_before>var assert = require('chai').assert;
var expect = require('chai').expect;
var dbConnection = require('../lib/dbConnection');

describe('dbConnection', function () {
  it('handles no input', function() {
    expect(dbConnection).to.throw(Error);
  });

  //This works though I think it's logic in pg-promise or pg.
  // it('handles empty object', function() {
  //   //expect(() => dbConnection({})).to.throw(Error);
  //   var conn = dbConnection({});
  //   conn.one('SELECT version();')
  //     .then(function(r) {
  //       assert.isNotNull(r);
  //       assert.isNotNull(r.version);
  //     })
  //     .error(function(er){
  //       assert.fail(er);
  //     });
  // });

  it('Constructs with string', function () {
    var conn = dbConnection("postgresql://localhost:5432/pg_migrate");
    conn.one('SELECT version();')
      .then(function(r) {
        assert.isNotNull(r);
        assert.isNotNull(r.version);
      })
      .error(function(er){
        assert.fail(er);
      });
  });

  it('Constructs with object', function () {
    var conObj = {
      user: '',
      password: '',
      host: "localhost",
      port: 5432,
      database: 'pg_migrate',
      max: 2,
      disconnect: function(client, dc) {
        console.log('disconnect');
      }
    };
    var conn = dbConnection(conObj);
    conn.one('SELECT version();')
      .then(function(r) {
        assert.isNotNull(r);
        assert.isNotNull(r.version);
      })
      .error(function(er){
        assert.fail(er);
      });
  });
});<commit_msg>return the promise for mocha's result.<commit_after>var assert = require('chai').assert;
var expect = require('chai').expect;
var dbConnection = require('../lib/dbConnection');

describe('dbConnection', function () {
  it('handles no input', function() {
    expect(dbConnection).to.throw(Error);
  });

  //This works though I think it's logic in pg-promise or pg.
  // it('handles empty object', function() {
  //   //expect(() => dbConnection({})).to.throw(Error);
  //   var conn = dbConnection({});
  //   conn.one('SELECT version();')
  //     .then(function(r) {
  //       assert.isNotNull(r);
  //       assert.isNotNull(r.version);
  //     })
  //     .error(function(er){
  //       assert.fail(er);
  //     });
  // });

  it('Constructs with string', function () {
    var conn = dbConnection("postgresql://localhost:5432/pg_migrate");
    conn.one('SELECT version();')
      .then(function(r) {
        assert.isNotNull(r);
        assert.isNotNull(r.version);
      })
      .error(function(er){
        assert.fail(er);
      });
    return conn;
  });

  it('Constructs with object', function () {
    var conObj = {
      user: '',
      password: '',
      host: "localhost",
      port: 5432,
      database: 'pg_migrate',
      max: 2,
      disconnect: function(client, dc) {
        console.log('disconnect');
      }
    };
    var conn = dbConnection(conObj);
    conn.one('SELECT version();')
      .then(function(r) {
        assert.isNotNull(r);
        assert.isNotNull(r.version);
      })
      .error(function(er){
        assert.fail(er);
      });
    return conn;
  });
});
{'fraction_non_alphanumeric': 0.1879152167035748, 'fraction_numerical': 0.005694400506168934, 'mean_word_length': 2.3602550478214663, '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': '618857', 'n_tokens_mistral': 1021, 'n_tokens_neox': 1001, 'n_words': 183}