File tree 2 files changed +17
-9
lines changed
2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ Pool.prototype._create = function (cb) {
96
96
client . connect ( function ( err ) {
97
97
if ( err ) {
98
98
this . log ( 'client connection error:' , err )
99
- cb ( err , client )
99
+ cb ( err , null )
100
100
} else {
101
101
this . log ( 'client connected' )
102
102
this . emit ( 'connect' , client )
Original file line number Diff line number Diff line change @@ -4,18 +4,26 @@ var it = require('mocha').it
4
4
var Pool = require ( '../' )
5
5
6
6
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
+
8
10
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
10
22
} )
23
+
11
24
pool . connect ( function ( err , client ) {
12
25
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 ( )
19
27
} )
20
28
} )
21
29
} )
You can’t perform that action at this time.
0 commit comments