@@ -392,9 +392,11 @@ describe('Lib', function () {
392
392
var DATA = require ( './mock/data/dbConnectInfo' ) ;
393
393
394
394
function prepareConnection ( segmentData ) {
395
- var connection = createConnection ( ) ;
396
-
397
- connection . send = function ( msg , cb ) {
395
+ var connection = createConnection ( ) ;
396
+ connection . _socket = {
397
+ readyState : 'open'
398
+ } ;
399
+ connection . send = function ( msg , cb ) {
398
400
var segment = new lib . reply . Segment ( segmentData . kind , segmentData . functionCode ) ;
399
401
var part = segmentData . parts [ 0 ] ;
400
402
segment . push ( new lib . reply . Part ( part . kind , part . attributes , part . argumentCount , part . buffer ) ) ;
@@ -404,39 +406,26 @@ describe('Lib', function () {
404
406
return connection ;
405
407
}
406
408
407
- it ( 'should fetch DB_CONNECT_INFO (not connected) ' , function ( done ) {
409
+ it ( 'should fetch DB_CONNECT_INFO with an error ' , function ( done ) {
408
410
var connection = prepareConnection ( DATA . NOT_CONNECTED ) ;
411
+ connection . _socket = undefined ;
409
412
410
413
connection . fetchDbConnectInfo ( { } , function ( err , info ) {
411
- info . isConnected . should . equal ( false ) ;
412
- info . host . should . equal ( '12.34.56.123' ) ;
413
- info . port . should . equal ( 31144 ) ;
414
+ err . code . should . equal ( 'EHDBCLOSE' )
414
415
done ( ) ;
415
416
} ) ;
416
417
} ) ;
417
418
418
419
it ( 'should fetch DB_CONNECT_INFO (connected)' , function ( done ) {
419
420
var connection = prepareConnection ( DATA . CONNECTED ) ;
420
-
421
+ connection . _queue . resume ( ) ;
421
422
connection . fetchDbConnectInfo ( { } , function ( err , info ) {
422
423
info . isConnected . should . equal ( true ) ;
423
424
( ! ! info . host ) . should . be . not . ok ;
424
425
( ! ! info . port ) . should . be . not . ok ;
425
426
done ( ) ;
426
427
} ) ;
427
428
} ) ;
428
-
429
- it ( 'fetch DB_CONNECT_INFO with an error' , function ( done ) {
430
- var connection = createConnection ( ) ;
431
- connection . send = function ( msg , cb ) {
432
- cb ( new Error ( 'Request was not successful' ) ) ;
433
- } ;
434
-
435
- connection . fetchDbConnectInfo ( { } , function ( err ) {
436
- err . message . should . equal ( 'Request was not successful' ) ;
437
- done ( ) ;
438
- } ) ;
439
- } ) ;
440
429
} ) ;
441
430
442
431
it ( 'should connect to the database' , function ( done ) {
0 commit comments