1- return console . log ( 'cancel-query-tests.js: GET TO PASS' ) ;
21var helper = require ( __dirname + "/test-helper" ) ;
32
43//before running this test make sure you run the script create-test-tables
@@ -10,35 +9,29 @@ test("cancellation of a query", function() {
109
1110 client . on ( 'drain' , client . end . bind ( client ) ) ;
1211
13- var rows1 = 0 , rows2 = 0 , rows3 = 0 , rows4 = 0 ;
12+ var rows3 = 0 ;
1413
1514 var query1 = client . query ( qry ) ;
1615 query1 . on ( 'row' , function ( row ) {
17- rows1 ++ ;
16+ throw new Error ( 'Should not emit a row' )
1817 } ) ;
1918 var query2 = client . query ( qry ) ;
2019 query2 . on ( 'row' , function ( row ) {
21- rows2 ++ ;
20+ throw new Error ( 'Should not emit a row' )
2221 } ) ;
2322 var query3 = client . query ( qry ) ;
2423 query3 . on ( 'row' , function ( row ) {
2524 rows3 ++ ;
2625 } ) ;
2726 var query4 = client . query ( qry ) ;
2827 query4 . on ( 'row' , function ( row ) {
29- rows4 ++ ;
28+ throw new Error ( 'Should not emit a row' )
3029 } ) ;
3130
3231 helper . pg . cancel ( helper . config , client , query1 ) ;
3332 helper . pg . cancel ( helper . config , client , query2 ) ;
3433 helper . pg . cancel ( helper . config , client , query4 ) ;
3534
36- setTimeout ( function ( ) {
37- assert . equal ( rows1 , 0 ) ;
38- assert . equal ( rows2 , 0 ) ;
39- assert . equal ( rows4 , 0 ) ;
40- } , 2000 ) ;
41-
4235 assert . emits ( query3 , 'end' , function ( ) {
4336 test ( "returned right number of rows" , function ( ) {
4437 assert . equal ( rows3 , 26 ) ;
0 commit comments