1
1
var helper = require ( __dirname + '/test-helper' ) ;
2
- var sys = require ( 'sys' )
2
+ var sys = require ( 'sys' ) ;
3
3
4
4
var createErorrClient = function ( ) {
5
5
var client = helper . client ( ) ;
6
6
client . on ( 'error' , function ( err ) {
7
7
assert . ok ( false , "client should not throw query error: " + sys . inspect ( err ) ) ;
8
- } )
8
+ } ) ;
9
9
client . on ( 'drain' , client . end . bind ( client ) ) ;
10
10
return client ;
11
11
} ;
@@ -21,7 +21,7 @@ test('error handling', function(){
21
21
assert . emits ( query , 'error' , function ( error ) {
22
22
test ( 'error is a psql error' , function ( ) {
23
23
assert . equal ( error . severity , "ERROR" ) ;
24
- } )
24
+ } ) ;
25
25
} ) ;
26
26
27
27
} ) ;
@@ -54,9 +54,9 @@ test('error handling', function(){
54
54
assert . emits ( query , 'error' , function ( err ) {
55
55
ensureFuture ( client ) ;
56
56
} ) ;
57
- } )
57
+ } ) ;
58
58
59
- test ( "when a query is binding" , function ( ) {
59
+ test ( "when a query is binding" , function ( ) {
60
60
61
61
var query = client . query ( {
62
62
text : 'select * from boom where age = $1' ,
@@ -76,7 +76,7 @@ test('error handling', function(){
76
76
77
77
//TODO how to test for errors during execution?
78
78
} ) ;
79
- } )
79
+ } ) ;
80
80
} ) ;
81
81
82
82
test ( 'non-query error' , function ( ) {
@@ -88,18 +88,38 @@ test('error handling', function(){
88
88
client . connect ( ) ;
89
89
} ) ;
90
90
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
+
91
101
} ) ;
92
102
93
103
test ( 'when connecting to invalid host' , function ( ) {
94
- return false ;
95
104
var client = new Client ( {
96
105
user : 'brian' ,
97
106
password : '1234' ,
98
107
host : 'asldkfjasdf!!#1308140.com'
99
- } )
108
+ } ) ;
100
109
assert . emits ( client , 'error' ) ;
101
110
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
+ } ) ;
103
123
104
124
test ( 'multiple connection errors (gh#31)' , function ( ) {
105
125
return false ;
@@ -111,18 +131,18 @@ test('multiple connection errors (gh#31)', function() {
111
131
host : helper . args . host ,
112
132
port : helper . args . port ,
113
133
database : helper . args . database
114
- } )
134
+ } ) ;
115
135
client . connect ( ) ;
116
136
assert . emits ( client , 'error' , function ( e ) {
117
137
client . connect ( ) ;
118
- assert . emits ( client , 'error' )
119
- } )
120
- } )
138
+ assert . emits ( client , 'error' ) ;
139
+ } ) ;
140
+ } ) ;
121
141
122
142
test ( 'with callback method' , function ( ) {
123
143
var badConString = "tcp://aslkdfj:oi14081@" + helper . args . host + ":" + helper . args . port + "/" + helper . args . database ;
124
144
return false ;
125
- } )
145
+ } ) ;
126
146
127
- } )
147
+ } ) ;
128
148
0 commit comments