@@ -85,7 +85,7 @@ assert.length = function(actual, expectedLength) {
85
85
var expect = function ( callback , timeout ) {
86
86
var executed = false ;
87
87
var id = setTimeout ( function ( ) {
88
- assert . ok ( executed , "Expected execution of " + callback + " fired") ;
88
+ assert . ok ( executed , "Expected execution of funtion to be fired" ) ;
89
89
} , timeout || 2000 )
90
90
91
91
return function ( err , queryResult ) {
@@ -140,7 +140,42 @@ process.on('exit', function() {
140
140
throw error . e ;
141
141
} ) ;
142
142
} ) ;
143
+ var count = 0 ;
144
+
145
+ var Sink = function ( expected , timeout , callback ) {
146
+ var defaultTimeout = 1000 ;
147
+ if ( typeof timeout == 'function' ) {
148
+ callback = timeout ;
149
+ timeout = defaultTimeout ;
150
+ }
151
+ timeout = timeout || defaultTimeout ;
152
+ var internalCount = 0 ;
153
+ var kill = function ( ) {
154
+ assert . ok ( false , "Did not reach expected " + expected + " with an idle timeout of " + timeout ) ;
155
+ }
156
+ var killTimeout = setTimeout ( kill , timeout ) ;
157
+ return {
158
+ add : function ( count ) {
159
+ count = count || 1 ;
160
+ internalCount += count ;
161
+ clearTimeout ( killTimeout )
162
+ if ( internalCount < expected ) {
163
+ killTimeout = setTimeout ( kill , timeout )
164
+ }
165
+ else {
166
+ assert . equal ( internalCount , expected ) ;
167
+ callback ( ) ;
168
+ }
169
+ }
170
+ }
171
+ }
143
172
144
173
module . exports = {
145
- args : args
174
+ args : args ,
175
+ Sink : Sink ,
176
+ connectionString : function ( ) {
177
+ return "pg" + ( count ++ ) + "://" + args . user + ":" + args . password + "@" + args . host + ":" + args . port + "/" + args . database ;
178
+ }
146
179
} ;
180
+
181
+
0 commit comments