From e1ace21bf0b281ff16ab0b8fe996ef3356da06c6 Mon Sep 17 00:00:00 2001 From: Antonio Barcelos Date: Thu, 22 Apr 2021 16:35:46 +0200 Subject: [PATCH 1/2] fix Ipv6 Routing Table stub test The test was depending in internal of the driver which changed during this release cycle. --- test/internal/node/routing.driver.boltkit.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/internal/node/routing.driver.boltkit.test.js b/test/internal/node/routing.driver.boltkit.test.js index 907758d13..3c22d7d3e 100644 --- a/test/internal/node/routing.driver.boltkit.test.js +++ b/test/internal/node/routing.driver.boltkit.test.js @@ -52,7 +52,7 @@ describe('#stub-routing routing driver with stub server', () => { ]) assertHasRouters(driver, [ '[ff02::1]:9001', - '[684d:1111:222:3333:4444:5555:6:77]:9002', + '[684D:1111:222:3333:4444:5555:6:77]:9002', '[::1]:9003' ]) @@ -64,7 +64,7 @@ describe('#stub-routing routing driver with stub server', () => { ]) assertHasRouters(driver, [ '[ff02::1]:9001', - '[684d:1111:222:3333:4444:5555:6:77]:9002', + '[684D:1111:222:3333:4444:5555:6:77]:9002', '[::1]:9003' ]) @@ -615,9 +615,9 @@ describe('#stub-routing routing driver with stub server', () => { return connectionProvider._connectionPool } - function getRoutingTable (driver, database) { + function getRoutingTable (driver, database = null) { const connectionProvider = driver._getOrCreateConnectionProvider() - return connectionProvider._routingTableRegistry.get(database || '', {}) + return connectionProvider._routingTableRegistry.get(database, {}) } function numberOfOpenConnections (driver) { From 89f4fe63fa6cea607db11a7e1e28fa41cd1c3f0a Mon Sep 17 00:00:00 2001 From: Antonio Barcelos Date: Thu, 22 Apr 2021 18:05:11 +0200 Subject: [PATCH 2/2] Moving some session tests from integration to unit test This tests were missplaced and do not depend on a real connection with the database. --- test/session.test.js | 60 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/test/session.test.js b/test/session.test.js index 092a983bb..4f11975f4 100644 --- a/test/session.test.js +++ b/test/session.test.js @@ -40,26 +40,7 @@ const { const { PROTOCOL_ERROR, SESSION_EXPIRED } = error -describe('#integration session', () => { - let driver - let session - // eslint-disable-next-line no-unused-vars - let protocolVersion - - beforeEach(async () => { - driver = neo4j.driver( - `bolt://${sharedNeo4j.hostname}`, - sharedNeo4j.authToken - ) - session = driver.session() - - protocolVersion = await sharedNeo4j.cleanupAndGetProtocolVersion(driver) - }) - - afterEach(async () => { - await driver.close() - }) - +describe('#unit session', () => { it('close should return promise', done => { const connection = new FakeConnection() const session = newSessionWithConnection(connection) @@ -114,6 +95,27 @@ describe('#integration session', () => { done() }) }, 70000) +}) + +describe('#integration session', () => { + let driver + let session + // eslint-disable-next-line no-unused-vars + let protocolVersion + + beforeEach(async () => { + driver = neo4j.driver( + `bolt://${sharedNeo4j.hostname}`, + sharedNeo4j.authToken + ) + session = driver.session() + + protocolVersion = await sharedNeo4j.cleanupAndGetProtocolVersion(driver) + }) + + afterEach(async () => { + await driver.close() + }) it('should be possible to close driver after closing session with failed tx ', done => { const driver = neo4j.driver( @@ -1194,15 +1196,6 @@ describe('#integration session', () => { .then(() => callback()) } - function newSessionWithConnection (connection) { - const connectionProvider = new SingleConnectionProvider( - Promise.resolve(connection) - ) - const session = new Session({ mode: READ, connectionProvider }) - session.beginTransaction() // force session to acquire new connection - return session - } - function idleConnectionCount (driver) { const connectionProvider = driver._connectionProvider const address = connectionProvider._address @@ -1311,3 +1304,12 @@ describe('#integration session', () => { }) } }) + +function newSessionWithConnection (connection) { + const connectionProvider = new SingleConnectionProvider( + Promise.resolve(connection) + ) + const session = new Session({ mode: READ, connectionProvider }) + session.beginTransaction() // force session to acquire new connection + return session +}