@@ -10,6 +10,19 @@ function getConInfo (override) {
10
10
return Object . assign ( { } , conInfo , override )
11
11
}
12
12
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
+
13
26
function getIdleTransactionSessionTimeout ( conf , cb ) {
14
27
var client = new Client ( conf )
15
28
client . connect ( assert . success ( function ( ) {
@@ -22,42 +35,43 @@ function getIdleTransactionSessionTimeout (conf, cb) {
22
35
}
23
36
24
37
if ( ! 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
+ } )
30
45
} )
31
- } )
32
46
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
+ } )
36
55
} )
37
- getIdleTransactionSessionTimeout ( conf , function ( res ) {
38
- assert . strictEqual ( res , '3s' )
39
- done ( )
40
- } )
41
- } )
42
56
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
+ } )
50
65
} )
51
- } )
52
66
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
+ } )
60
75
} )
61
76
} )
62
-
63
77
}
0 commit comments