@@ -54,7 +54,10 @@ describe('Hapi server', () => {
54
54
await server . register ( {
55
55
plugin : require ( '../' ) ,
56
56
options : {
57
- url : 'mongodb://localhost:27018'
57
+ url : 'mongodb://localhost:27018' ,
58
+ settings : {
59
+ serverSelectionTimeoutMS : 500
60
+ }
58
61
}
59
62
} ) ;
60
63
}
@@ -97,7 +100,7 @@ describe('Hapi server', () => {
97
100
} ) ;
98
101
} ) ;
99
102
100
- it ( 'should log configuration upon successfull connection, obscurifying DB password' , async ( ) => {
103
+ it ( 'should log configuration upon successful connection, obscurifying DB password' , async ( ) => {
101
104
102
105
let logEntry ;
103
106
server . events . once ( 'log' , ( entry ) => {
@@ -111,7 +114,7 @@ describe('Hapi server', () => {
111
114
112
115
Mongodb . MongoClient . connect = originalConnect ;
113
116
expect ( url ) . to . equal ( 'mongodb://user:[email protected] :27017' ) ;
114
- expect ( options ) . to . equal ( { poolSize : 11 } ) ;
117
+ expect ( options ) . to . equal ( { maxPoolSize : 11 } ) ;
115
118
connected = true ;
116
119
return Promise . resolve ( { db : ( ) => 'test-db' } ) ;
117
120
} ;
@@ -121,7 +124,7 @@ describe('Hapi server', () => {
121
124
options : {
122
125
url :
'mongodb://user:[email protected] :27017' ,
123
126
settings : {
124
- poolSize : 11
127
+ maxPoolSize : 11
125
128
}
126
129
}
127
130
} ) ;
@@ -131,7 +134,7 @@ describe('Hapi server', () => {
131
134
channel : 'app' ,
132
135
timestamp : logEntry . timestamp ,
133
136
tags : [ 'hapi-mongodb' , 'info' ] ,
134
- data : 'MongoClient connection created for {"url":"mongodb://user:******@example.com:27017","settings":{"poolSize ":11}}'
137
+ data : 'MongoClient connection created for {"url":"mongodb://user:******@example.com:27017","settings":{"maxPoolSize ":11}}'
135
138
} ) ;
136
139
} ) ;
137
140
@@ -142,7 +145,7 @@ describe('Hapi server', () => {
142
145
options : {
143
146
url : 'mongodb://localhost:27017' ,
144
147
settings : {
145
- poolSize : 10
148
+ maxPoolSize : 10
146
149
}
147
150
}
148
151
} ) ;
@@ -320,12 +323,12 @@ describe('Hapi server', () => {
320
323
321
324
await server . initialize ( ) ;
322
325
323
- expect ( server . plugins [ 'hapi-mongodb' ] . client . isConnected ( ) ) . to . be . true ( ) ;
326
+ expect ( server . plugins [ 'hapi-mongodb' ] . client . topology . isConnected ( ) ) . to . be . true ( ) ;
324
327
325
328
await server . stop ( ) ;
326
329
await Hoek . wait ( 100 ) ; // Let the connections end.
327
330
328
- expect ( server . plugins [ 'hapi-mongodb' ] . client . isConnected ( ) ) . to . be . false ( ) ;
331
+ expect ( server . plugins [ 'hapi-mongodb' ] . client . topology ) . to . be . undefined ( ) ;
329
332
} ) ;
330
333
331
334
it ( 'should logs errors on disconnect' , async ( ) => {
@@ -342,7 +345,7 @@ describe('Hapi server', () => {
342
345
343
346
await server . initialize ( ) ;
344
347
345
- expect ( server . plugins [ 'hapi-mongodb' ] . client . isConnected ( ) ) . to . be . true ( ) ;
348
+ expect ( server . plugins [ 'hapi-mongodb' ] . client . topology . isConnected ( ) ) . to . be . true ( ) ;
346
349
const closeStub = Sinon . stub ( server . plugins [ 'hapi-mongodb' ] . client , 'close' ) . callsFake ( ( cb ) => {
347
350
348
351
setTimeout ( cb , 0 , new Error ( 'Oops' ) ) ;
0 commit comments