1
- return console . log ( 'cancel-query-tests.js: GET TO PASS' ) ;
2
1
var helper = require ( __dirname + "/test-helper" ) ;
3
2
4
3
//before running this test make sure you run the script create-test-tables
@@ -10,35 +9,29 @@ test("cancellation of a query", function() {
10
9
11
10
client . on ( 'drain' , client . end . bind ( client ) ) ;
12
11
13
- var rows1 = 0 , rows2 = 0 , rows3 = 0 , rows4 = 0 ;
12
+ var rows3 = 0 ;
14
13
15
14
var query1 = client . query ( qry ) ;
16
15
query1 . on ( 'row' , function ( row ) {
17
- rows1 ++ ;
16
+ throw new Error ( 'Should not emit a row' )
18
17
} ) ;
19
18
var query2 = client . query ( qry ) ;
20
19
query2 . on ( 'row' , function ( row ) {
21
- rows2 ++ ;
20
+ throw new Error ( 'Should not emit a row' )
22
21
} ) ;
23
22
var query3 = client . query ( qry ) ;
24
23
query3 . on ( 'row' , function ( row ) {
25
24
rows3 ++ ;
26
25
} ) ;
27
26
var query4 = client . query ( qry ) ;
28
27
query4 . on ( 'row' , function ( row ) {
29
- rows4 ++ ;
28
+ throw new Error ( 'Should not emit a row' )
30
29
} ) ;
31
30
32
31
helper . pg . cancel ( helper . config , client , query1 ) ;
33
32
helper . pg . cancel ( helper . config , client , query2 ) ;
34
33
helper . pg . cancel ( helper . config , client , query4 ) ;
35
34
36
- setTimeout ( function ( ) {
37
- assert . equal ( rows1 , 0 ) ;
38
- assert . equal ( rows2 , 0 ) ;
39
- assert . equal ( rows4 , 0 ) ;
40
- } , 2000 ) ;
41
-
42
35
assert . emits ( query3 , 'end' , function ( ) {
43
36
test ( "returned right number of rows" , function ( ) {
44
37
assert . equal ( rows3 , 26 ) ;
0 commit comments