Skip to content

Commit 7b29704

Browse files
authored
Fix error check in the bolt-v3.test (#947)
* Fix error check in the bolt-v3.test * Check if database supports during v3 tests
1 parent cc4598b commit 7b29704

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

packages/neo4j-driver/test/bolt-v3.test.js

+21-7
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('#integration Bolt V3 API', () => {
5151
})
5252

5353
it('should set transaction metadata for auto-commit transaction', async () => {
54-
if (!databaseSupportsBoltV3() || !databaseSupportsListTransaction()) {
54+
if (!databaseSupportsBoltV3() || !(await databaseSupportsListTransaction())) {
5555
return
5656
}
5757

@@ -93,7 +93,8 @@ describe('#integration Bolt V3 API', () => {
9393
// ClientError on 4.1 and later
9494
if (
9595
e.code !== 'Neo.ClientError.Transaction.TransactionTimedOut' &&
96-
e.code !== 'Neo.TransientError.Transaction.LockClientStopped'
96+
e.code !== 'Neo.TransientError.Transaction.LockClientStopped' &&
97+
e.code !== 'Neo.ClientError.Transaction.LockClientStopped'
9798
) {
9899
fail('Expected transaction timeout error but got: ' + e.code)
99100
}
@@ -173,7 +174,7 @@ describe('#integration Bolt V3 API', () => {
173174
)
174175

175176
it('should set transaction metadata for explicit transactions', async () => {
176-
if (!databaseSupportsBoltV3() || !databaseSupportsListTransaction()) {
177+
if (!databaseSupportsBoltV3() || !(await databaseSupportsListTransaction())) {
177178
return
178179
}
179180

@@ -216,7 +217,8 @@ describe('#integration Bolt V3 API', () => {
216217
// ClientError on 4.1 and later
217218
if (
218219
e.code !== 'Neo.ClientError.Transaction.TransactionTimedOut' &&
219-
e.code !== 'Neo.TransientError.Transaction.LockClientStopped'
220+
e.code !== 'Neo.TransientError.Transaction.LockClientStopped' &&
221+
e.code !== 'Neo.ClientError.Transaction.LockClientStopped'
220222
) {
221223
fail('Expected transaction timeout error but got: ' + e.code)
222224
}
@@ -448,7 +450,7 @@ describe('#integration Bolt V3 API', () => {
448450
}, 20000)
449451

450452
async function testTransactionMetadataWithTransactionFunctions (read) {
451-
if (!databaseSupportsBoltV3() || !databaseSupportsListTransaction()) {
453+
if (!databaseSupportsBoltV3() || !(await databaseSupportsListTransaction())) {
452454
return
453455
}
454456

@@ -552,7 +554,19 @@ describe('#integration Bolt V3 API', () => {
552554
return protocolVersion >= 3
553555
}
554556

555-
function databaseSupportsListTransaction () {
556-
return sharedNeo4j.edition === 'enterprise'
557+
async function databaseSupportsListTransaction () {
558+
if (sharedNeo4j.edition === 'enterprise') {
559+
try {
560+
await session.run(
561+
'CALL dbms.listTransactions()',
562+
{}
563+
)
564+
return true
565+
} catch (e) {
566+
console.error('Database does not support dbms.listTransactions()', e)
567+
return false
568+
}
569+
}
570+
return false
557571
}
558572
})

0 commit comments

Comments
 (0)