@@ -10,6 +10,19 @@ function getConInfo (override) {
1010 return Object . assign ( { } , conInfo , override )
1111}
1212
13+ function testClientVersion ( cb ) {
14+ var client = new Client ( { } )
15+ client . connect ( assert . success ( function ( ) {
16+ helper . versionGTE ( client , 100000 , assert . success ( function ( isGreater ) {
17+ if ( ! isGreater ) {
18+ console . log ( 'skip idle_in_transaction_session_timeout at client-level is only available in v10 and above' ) ;
19+ return client . end ( ) ;
20+ }
21+ cb ( ) ;
22+ } ) )
23+ } ) )
24+ }
25+
1326function getIdleTransactionSessionTimeout ( conf , cb ) {
1427 var client = new Client ( conf )
1528 client . connect ( assert . success ( function ( ) {
@@ -22,42 +35,43 @@ function getIdleTransactionSessionTimeout (conf, cb) {
2235}
2336
2437if ( ! helper . args . native ) { // idle_in_transaction_session_timeout is not supported with the native client
25- suite . test ( 'No default idle_in_transaction_session_timeout ' , function ( done ) {
26- getConInfo ( )
27- getIdleTransactionSessionTimeout ( { } , function ( res ) {
28- assert . strictEqual ( res , '0' ) // 0 = no timeout
29- done ( )
38+ testClientVersion ( function ( ) {
39+ suite . test ( 'No default idle_in_transaction_session_timeout ' , function ( done ) {
40+ getConInfo ( )
41+ getIdleTransactionSessionTimeout ( { } , function ( res ) {
42+ assert . strictEqual ( res , '0' ) // 0 = no timeout
43+ done ( )
44+ } )
3045 } )
31- } )
3246
33- suite . test ( 'idle_in_transaction_session_timeout integer is used' , function ( done ) {
34- var conf = getConInfo ( {
35- 'idle_in_transaction_session_timeout' : 3000
47+ suite . test ( 'idle_in_transaction_session_timeout integer is used' , function ( done ) {
48+ var conf = getConInfo ( {
49+ 'idle_in_transaction_session_timeout' : 3000
50+ } )
51+ getIdleTransactionSessionTimeout ( conf , function ( res ) {
52+ assert . strictEqual ( res , '3s' )
53+ done ( )
54+ } )
3655 } )
37- getIdleTransactionSessionTimeout ( conf , function ( res ) {
38- assert . strictEqual ( res , '3s' )
39- done ( )
40- } )
41- } )
4256
43- suite . test ( 'idle_in_transaction_session_timeout float is used' , function ( done ) {
44- var conf = getConInfo ( {
45- 'idle_in_transaction_session_timeout' : 3000.7
46- } )
47- getIdleTransactionSessionTimeout ( conf , function ( res ) {
48- assert . strictEqual ( res , '3s' )
49- done ( )
57+ suite . test ( 'idle_in_transaction_session_timeout float is used' , function ( done ) {
58+ var conf = getConInfo ( {
59+ 'idle_in_transaction_session_timeout' : 3000.7
60+ } )
61+ getIdleTransactionSessionTimeout ( conf , function ( res ) {
62+ assert . strictEqual ( res , '3s' )
63+ done ( )
64+ } )
5065 } )
51- } )
5266
53- suite . test ( 'idle_in_transaction_session_timeout string is used' , function ( done ) {
54- var conf = getConInfo ( {
55- 'idle_in_transaction_session_timeout' : '3000'
56- } )
57- getIdleTransactionSessionTimeout ( conf , function ( res ) {
58- assert . strictEqual ( res , '3s' )
59- done ( )
67+ suite . test ( 'idle_in_transaction_session_timeout string is used' , function ( done ) {
68+ var conf = getConInfo ( {
69+ 'idle_in_transaction_session_timeout' : '3000'
70+ } )
71+ getIdleTransactionSessionTimeout ( conf , function ( res ) {
72+ assert . strictEqual ( res , '3s' )
73+ done ( )
74+ } )
6075 } )
6176 } )
62-
6377}
0 commit comments