File tree 2 files changed +15
-2
lines changed
test/integration/connection-pool
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -19,15 +19,23 @@ util.inherits(PG, EventEmitter);
19
19
20
20
PG . prototype . end = function ( ) {
21
21
var self = this ;
22
- Object . keys ( self . pools . all ) . forEach ( function ( key ) {
22
+ var keys = Object . keys ( self . pools . all ) ;
23
+ var count = keys . length ;
24
+ keys . forEach ( function ( key ) {
23
25
var pool = self . pools . all [ key ] ;
24
26
delete self . pools . all [ key ] ;
25
27
pool . drain ( function ( ) {
26
- pool . destroyAllNow ( ) ;
28
+ pool . destroyAllNow ( function ( ) {
29
+ count -- ;
30
+ if ( count === 0 ) {
31
+ self . emit ( 'end' ) ;
32
+ }
33
+ } ) ;
27
34
} ) ;
28
35
} ) ;
29
36
} ;
30
37
38
+
31
39
PG . prototype . connect = function ( config , callback ) {
32
40
if ( typeof config == "function" ) {
33
41
callback = config ;
Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ var called = false;
4
4
test ( 'disconnects' , function ( ) {
5
5
var sink = new helper . Sink ( 4 , function ( ) {
6
6
called = true ;
7
+ var eventSink = new helper . Sink ( 1 , function ( ) { } ) ;
8
+ helper . pg . on ( 'end' , function ( ) {
9
+ eventSink . add ( ) ;
10
+ } ) ;
11
+
7
12
//this should exit the process, killing each connection pool
8
13
helper . pg . end ( ) ;
9
14
} ) ;
You can’t perform that action at this time.
0 commit comments