@@ -92,13 +92,7 @@ describe('Bolt V3 API', () => {
92
92
session . run ( 'MATCH (n:Node) SET n.prop = $newValue' , { newValue : 2 } , { timeout : 1 } )
93
93
. then ( ( ) => done . fail ( 'Failure expected' ) )
94
94
. catch ( error => {
95
- const hasExpectedCode = error . code . indexOf ( 'TransientError' ) !== - 1 ;
96
- const hasExpectedMessage = error . message . indexOf ( 'transaction has been terminated' ) !== - 1 ;
97
- if ( ! hasExpectedCode || ! hasExpectedMessage ) {
98
- console . log ( `Unexpected error with code ${ error . code } ` , error ) ;
99
- }
100
- expect ( hasExpectedCode ) . toBeTruthy ( ) ;
101
- expect ( hasExpectedMessage ) . toBeTruthy ( ) ;
95
+ expectTransactionTerminatedError ( error ) ;
102
96
103
97
tx . rollback ( )
104
98
. then ( ( ) => otherSession . close ( ) )
@@ -185,8 +179,7 @@ describe('Bolt V3 API', () => {
185
179
tx . run ( 'MATCH (n:Node) SET n.prop = $newValue' , { newValue : 2 } )
186
180
. then ( ( ) => done . fail ( 'Failure expected' ) )
187
181
. catch ( error => {
188
- expect ( error . code . indexOf ( 'TransientError' ) ) . toBeGreaterThan ( 0 ) ;
189
- expect ( error . message . indexOf ( 'transaction has been terminated' ) ) . toBeGreaterThan ( 0 ) ;
182
+ expectTransactionTerminatedError ( error ) ;
190
183
191
184
otherTx . rollback ( )
192
185
. then ( ( ) => otherSession . close ( ) )
@@ -467,6 +460,14 @@ describe('Bolt V3 API', () => {
467
460
expect ( error . message . indexOf ( 'Driver is connected to the database that does not support transaction configuration' ) ) . toBeGreaterThan ( - 1 ) ;
468
461
}
469
462
463
+ function expectTransactionTerminatedError ( error ) {
464
+ const hasExpectedMessage = error . message . toLowerCase ( ) . indexOf ( 'transaction has been terminated' ) > - 1 ;
465
+ if ( ! hasExpectedMessage ) {
466
+ console . log ( `Unexpected error with code: ${ error . code } ` , error ) ;
467
+ }
468
+ expect ( hasExpectedMessage ) . toBeTruthy ( ) ;
469
+ }
470
+
470
471
function databaseSupportsBoltV3 ( ) {
471
472
return serverVersion . compareTo ( VERSION_3_5_0 ) >= 0 ;
472
473
}
0 commit comments