11var helper = require ( __dirname + '/test-helper' ) ;
2- var sys = require ( 'sys' )
2+ var sys = require ( 'sys' ) ;
33
44var createErorrClient = function ( ) {
55 var client = helper . client ( ) ;
66 client . on ( 'error' , function ( err ) {
77 assert . ok ( false , "client should not throw query error: " + sys . inspect ( err ) ) ;
8- } )
8+ } ) ;
99 client . on ( 'drain' , client . end . bind ( client ) ) ;
1010 return client ;
1111} ;
@@ -21,7 +21,7 @@ test('error handling', function(){
2121 assert . emits ( query , 'error' , function ( error ) {
2222 test ( 'error is a psql error' , function ( ) {
2323 assert . equal ( error . severity , "ERROR" ) ;
24- } )
24+ } ) ;
2525 } ) ;
2626
2727 } ) ;
@@ -54,9 +54,9 @@ test('error handling', function(){
5454 assert . emits ( query , 'error' , function ( err ) {
5555 ensureFuture ( client ) ;
5656 } ) ;
57- } )
57+ } ) ;
5858
59- test ( "when a query is binding" , function ( ) {
59+ test ( "when a query is binding" , function ( ) {
6060
6161 var query = client . query ( {
6262 text : 'select * from boom where age = $1' ,
@@ -76,7 +76,7 @@ test('error handling', function(){
7676
7777 //TODO how to test for errors during execution?
7878 } ) ;
79- } )
79+ } ) ;
8080 } ) ;
8181
8282 test ( 'non-query error' , function ( ) {
@@ -88,18 +88,38 @@ test('error handling', function(){
8888 client . connect ( ) ;
8989 } ) ;
9090
91+ test ( 'non-query error with callback' , function ( ) {
92+
93+ var client = new Client ( {
94+ user :'asldkfjsadlfkj'
95+ } ) ;
96+ client . connect ( function ( error , client ) {
97+ assert . ok ( error ) ;
98+ } ) ;
99+ } ) ;
100+
91101} ) ;
92102
93103test ( 'when connecting to invalid host' , function ( ) {
94- return false ;
95104 var client = new Client ( {
96105 user : 'brian' ,
97106 password : '1234' ,
98107 host : 'asldkfjasdf!!#1308140.com'
99- } )
108+ } ) ;
100109 assert . emits ( client , 'error' ) ;
101110 client . connect ( ) ;
102- } )
111+ } ) ;
112+
113+ test ( 'when connecting to invalid host with callback' , function ( ) {
114+ var client = new Client ( {
115+ user : 'brian' ,
116+ password : '1234' ,
117+ host : 'asldkfjasdf!!#1308140.com'
118+ } ) ;
119+ client . connect ( function ( error , client ) {
120+ assert . ok ( error ) ;
121+ } ) ;
122+ } ) ;
103123
104124test ( 'multiple connection errors (gh#31)' , function ( ) {
105125 return false ;
@@ -111,18 +131,18 @@ test('multiple connection errors (gh#31)', function() {
111131 host : helper . args . host ,
112132 port : helper . args . port ,
113133 database : helper . args . database
114- } )
134+ } ) ;
115135 client . connect ( ) ;
116136 assert . emits ( client , 'error' , function ( e ) {
117137 client . connect ( ) ;
118- assert . emits ( client , 'error' )
119- } )
120- } )
138+ assert . emits ( client , 'error' ) ;
139+ } ) ;
140+ } ) ;
121141
122142 test ( 'with callback method' , function ( ) {
123143 var badConString = "tcp://aslkdfj:oi14081@" + helper . args . host + ":" + helper . args . port + "/" + helper . args . database ;
124144 return false ;
125- } )
145+ } ) ;
126146
127- } )
147+ } ) ;
128148
0 commit comments