diff --git a/index.js b/index.js index aec3a1ec..ccad9686 100644 --- a/index.js +++ b/index.js @@ -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) diff --git a/test/connection-strings.js b/test/connection-strings.js new file mode 100644 index 00000000..cc624a14 --- /dev/null +++ b/test/connection-strings.js @@ -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') + }) + }) +}) +