Skip to content

Commit 5061068

Browse files
committed
Fix test
1 parent 959d89e commit 5061068

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Pool.prototype._create = function (cb) {
9696
client.connect(function (err) {
9797
if (err) {
9898
this.log('client connection error:', err)
99-
cb(err, client)
99+
cb(err, null)
100100
} else {
101101
this.log('client connected')
102102
this.emit('connect', client)

test/connection-strings.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@ var it = require('mocha').it
44
var Pool = require('../')
55

66
describe('Connection strings', function () {
7-
it('pool delegates connectionString property to client', function () {
7+
it('pool delegates connectionString property to client', function (done) {
8+
var connectionString = 'postgres://foo:bar@baz:1234/xur'
9+
810
var pool = new Pool({
9-
connectionString: 'postgres://foo:bar@baz:1234/xur'
11+
// use a fake client so we can check we're passed the connectionString
12+
Client: function (args) {
13+
expect(args.connectionString).to.equal(connectionString)
14+
return {
15+
connect: function (cb) {
16+
cb(new Error('testing'))
17+
},
18+
on: function () { }
19+
}
20+
},
21+
connectionString: connectionString
1022
})
23+
1124
pool.connect(function (err, client) {
1225
expect(err).to.not.be(undefined)
13-
expect(client).to.not.be(undefined)
14-
expect(client.username).to.equal('foo')
15-
expect(client.password).to.equal('bar')
16-
expect(client.database).to.equal('baz')
17-
expect(client.port).to.equal(1234)
18-
expect(client.database).to.equal('xur')
26+
done()
1927
})
2028
})
2129
})

0 commit comments

Comments
 (0)