Add test for connectionString property delegation

This commit is contained in:
brianc 2017-06-07 22:35:55 -05:00
parent f93385284d
commit 959d89e043
2 changed files with 23 additions and 1 deletions

View File

@ -96,7 +96,7 @@ Pool.prototype._create = function (cb) {
client.connect(function (err) {
if (err) {
this.log('client connection error:', err)
cb(err)
cb(err, client)
} else {
this.log('client connected')
this.emit('connect', client)

View File

@ -0,0 +1,22 @@
var expect = require('expect.js')
var describe = require('mocha').describe
var it = require('mocha').it
var Pool = require('../')
describe('Connection strings', function () {
it('pool delegates connectionString property to client', function () {
var pool = new Pool({
connectionString: 'postgres://foo:bar@baz:1234/xur'
})
pool.connect(function (err, client) {
expect(err).to.not.be(undefined)
expect(client).to.not.be(undefined)
expect(client.username).to.equal('foo')
expect(client.password).to.equal('bar')
expect(client.database).to.equal('baz')
expect(client.port).to.equal(1234)
expect(client.database).to.equal('xur')
})
})
})