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