@@ -15,25 +15,35 @@ describe('connection model connector', () => {
15
15
this . slow ( 2000 ) ;
16
16
this . timeout ( 10000 ) ;
17
17
18
- before ( require ( 'mongodb-runner/mocha/before' ) ( { port : 27018 , version : '4.0.0' } ) ) ;
18
+ before (
19
+ require ( 'mongodb-runner/mocha/before' ) ( { port : 27018 , version : '4.0.0' } )
20
+ ) ;
19
21
20
- after ( require ( 'mongodb-runner/mocha/after' ) ( { port : 27018 , version : '4.0.0' } ) ) ;
22
+ after (
23
+ require ( 'mongodb-runner/mocha/after' ) ( { port : 27018 , version : '4.0.0' } )
24
+ ) ;
21
25
22
- it ( 'should connect to `localhost:27018 with model`' , ( done ) => {
26
+ it ( 'should connect to `localhost:27018 with model`' , done => {
23
27
Connection . from ( 'mongodb://localhost:27018' , ( parseErr , model ) => {
24
28
assert . equal ( parseErr , null ) ;
25
- connect ( model , setupListeners , ( connectErr ) => {
29
+ connect ( model , setupListeners , ( connectErr , client ) => {
26
30
assert . equal ( connectErr , null ) ;
31
+ client . close ( true ) ;
27
32
done ( ) ;
28
33
} ) ;
29
34
} ) ;
30
35
} ) ;
31
36
32
- it ( 'should connect to `localhost:27018 with object`' , ( done ) => {
33
- connect ( { port : 27018 , host : 'localhost' } , setupListeners , ( err ) => {
34
- assert . equal ( err , null ) ;
35
- done ( ) ;
36
- } ) ;
37
+ it ( 'should connect to `localhost:27018 with object`' , done => {
38
+ connect (
39
+ { port : 27018 , host : 'localhost' } ,
40
+ setupListeners ,
41
+ ( err , client ) => {
42
+ assert . equal ( err , null ) ;
43
+ client . close ( true ) ;
44
+ done ( ) ;
45
+ }
46
+ ) ;
37
47
} ) ;
38
48
39
49
describe ( 'ssh tunnel failures' , ( ) => {
@@ -43,13 +53,13 @@ describe('connection model connector', () => {
43
53
// simulate successful tunnel creation
44
54
cb ( ) ;
45
55
// then return a mocked tunnel object with a spy close() function
46
- return { close : spy } ;
56
+ return { close : spy } ;
47
57
} ) ;
48
58
49
59
const MockConnection = mock . reRequire ( '../lib/extended-model' ) ;
50
60
const mockConnect = mock . reRequire ( '../lib/connect' ) ;
51
61
52
- it ( 'should close ssh tunnel if the connection fails' , ( done ) => {
62
+ it ( 'should close ssh tunnel if the connection fails' , done => {
53
63
const model = new MockConnection ( {
54
64
hostname : 'localhost' ,
55
65
port : '27017' ,
@@ -61,7 +71,7 @@ describe('connection model connector', () => {
61
71
} ) ;
62
72
63
73
assert ( model . isValid ( ) ) ;
64
- mockConnect ( model , setupListeners , ( err ) => {
74
+ mockConnect ( model , setupListeners , err => {
65
75
// must throw error here, because the connection details are invalid
66
76
assert . ok ( err ) ;
67
77
assert . ok ( / E C O N N R E F U S E D / . test ( err . reason ) ) ;
@@ -77,27 +87,27 @@ describe('connection model connector', () => {
77
87
this . slow ( 5000 ) ;
78
88
this . timeout ( 10000 ) ;
79
89
80
- data . MATRIX . map ( ( d ) => {
81
- it . skip ( 'should connect to ' + d . name , ( done ) => {
82
- connect ( d , setupListeners , ( err , _db ) => {
90
+ data . MATRIX . map ( d => {
91
+ it . skip ( 'should connect to ' + d . name , done => {
92
+ connect ( d , setupListeners , ( err , client ) => {
83
93
if ( err ) {
84
94
return done ( err ) ;
85
95
}
86
96
87
- _db . close ( ) ;
97
+ client . close ( true ) ;
88
98
done ( ) ;
89
99
} ) ;
90
100
} ) ;
91
101
} ) ;
92
102
93
- data . SSH_TUNNEL_MATRIX . map ( ( d ) => {
94
- it . skip ( `connects via the sshTunnel to ${ d . sshTunnelHostname } ` , ( done ) => {
95
- connect ( d , setupListeners , ( err , _db ) => {
103
+ data . SSH_TUNNEL_MATRIX . map ( d => {
104
+ it . skip ( `connects via the sshTunnel to ${ d . sshTunnelHostname } ` , done => {
105
+ connect ( d , setupListeners , ( err , client ) => {
96
106
if ( err ) {
97
107
return done ( err ) ;
98
108
}
99
109
100
- _db . close ( ) ;
110
+ client . close ( true ) ;
101
111
done ( ) ;
102
112
} ) ;
103
113
} ) ;
0 commit comments