@@ -21,6 +21,7 @@ import neo4j from '../../src/v1';
21
21
import sharedNeo4j from '../internal/shared-neo4j' ;
22
22
import FakeConnection from '../internal/fake-connection' ;
23
23
import lolex from 'lolex' ;
24
+ import { DEFAULT_ACQUISITION_TIMEOUT , DEFAULT_MAX_SIZE } from '../../src/v1/internal/pool-config' ;
24
25
25
26
describe ( 'driver' , ( ) => {
26
27
@@ -191,13 +192,10 @@ describe('driver', () => {
191
192
expect ( ( ) => neo4j . driver ( 'bolt://localhost:7687/?policy=my_policy' ) ) . toThrow ( ) ;
192
193
} ) ;
193
194
194
- it ( 'should sanitize maxConnectionLifetime in the config' , ( ) => {
195
- validateMaxConnectionLifetime ( { } , null ) ;
196
- validateMaxConnectionLifetime ( { maxConnectionLifetime : 42 } , 42 ) ;
197
- validateMaxConnectionLifetime ( { maxConnectionLifetime : 0 } , null ) ;
198
- validateMaxConnectionLifetime ( { maxConnectionLifetime : '42' } , 42 ) ;
199
- validateMaxConnectionLifetime ( { maxConnectionLifetime : '042' } , 42 ) ;
200
- validateMaxConnectionLifetime ( { maxConnectionLifetime : - 42 } , null ) ;
195
+ it ( 'should sanitize pool setting values in the config' , ( ) => {
196
+ testConfigSanitizing ( 'maxConnectionLifetime' , 60 * 60 * 1000 ) ;
197
+ testConfigSanitizing ( 'maxConnectionPoolSize' , DEFAULT_MAX_SIZE ) ;
198
+ testConfigSanitizing ( 'connectionAcquisitionTimeout' , DEFAULT_ACQUISITION_TIMEOUT ) ;
201
199
} ) ;
202
200
203
201
it ( 'should treat closed connections as invalid' , ( ) => {
@@ -321,10 +319,19 @@ describe('driver', () => {
321
319
return neo4j . auth . basic ( 'neo4j' , 'who would use such a password' ) ;
322
320
}
323
321
324
- function validateMaxConnectionLifetime ( config , expectedValue ) {
322
+ function testConfigSanitizing ( configProperty , defaultValue ) {
323
+ validateConfigSanitizing ( { } , defaultValue ) ;
324
+ validateConfigSanitizing ( { [ configProperty ] : 42 } , 42 ) ;
325
+ validateConfigSanitizing ( { [ configProperty ] : 0 } , 0 ) ;
326
+ validateConfigSanitizing ( { [ configProperty ] : '42' } , 42 ) ;
327
+ validateConfigSanitizing ( { [ configProperty ] : '042' } , 42 ) ;
328
+ validateConfigSanitizing ( { [ configProperty ] : - 42 } , Number . MAX_SAFE_INTEGER ) ;
329
+ }
330
+
331
+ function validateConfigSanitizing ( config , configProperty , expectedValue ) {
325
332
const driver = neo4j . driver ( 'bolt://localhost' , sharedNeo4j . authToken , config ) ;
326
333
try {
327
- expect ( driver . _config . maxConnectionLifetime ) . toEqual ( expectedValue ) ;
334
+ expect ( driver . _config [ configProperty ] ) . toEqual ( expectedValue ) ;
328
335
} finally {
329
336
driver . close ( ) ;
330
337
}
0 commit comments