Skip to content

Commit 30569c9

Browse files
committed
Moving some session tests from integration to unit test
This tests were missplaced and do not depend on a real connection with the database.
1 parent 6282fb0 commit 30569c9

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

test/session.test.js

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,7 @@ const {
4040

4141
const { PROTOCOL_ERROR, SESSION_EXPIRED } = error
4242

43-
describe('#integration session', () => {
44-
let driver
45-
let session
46-
// eslint-disable-next-line no-unused-vars
47-
let protocolVersion
48-
49-
beforeEach(async () => {
50-
driver = neo4j.driver(
51-
`bolt://${sharedNeo4j.hostname}`,
52-
sharedNeo4j.authToken
53-
)
54-
session = driver.session()
55-
56-
protocolVersion = await sharedNeo4j.cleanupAndGetProtocolVersion(driver)
57-
})
58-
59-
afterEach(async () => {
60-
await driver.close()
61-
})
62-
43+
describe('#unit session', () => {
6344
it('close should return promise', done => {
6445
const connection = new FakeConnection()
6546
const session = newSessionWithConnection(connection)
@@ -114,6 +95,27 @@ describe('#integration session', () => {
11495
done()
11596
})
11697
}, 70000)
98+
})
99+
100+
describe('#integration session', () => {
101+
let driver
102+
let session
103+
// eslint-disable-next-line no-unused-vars
104+
let protocolVersion
105+
106+
beforeEach(async () => {
107+
driver = neo4j.driver(
108+
`bolt://${sharedNeo4j.hostname}`,
109+
sharedNeo4j.authToken
110+
)
111+
session = driver.session()
112+
113+
protocolVersion = await sharedNeo4j.cleanupAndGetProtocolVersion(driver)
114+
})
115+
116+
afterEach(async () => {
117+
await driver.close()
118+
})
117119

118120
it('should be possible to close driver after closing session with failed tx ', done => {
119121
const driver = neo4j.driver(
@@ -1194,15 +1196,6 @@ describe('#integration session', () => {
11941196
.then(() => callback())
11951197
}
11961198

1197-
function newSessionWithConnection (connection) {
1198-
const connectionProvider = new SingleConnectionProvider(
1199-
Promise.resolve(connection)
1200-
)
1201-
const session = new Session({ mode: READ, connectionProvider })
1202-
session.beginTransaction() // force session to acquire new connection
1203-
return session
1204-
}
1205-
12061199
function idleConnectionCount (driver) {
12071200
const connectionProvider = driver._connectionProvider
12081201
const address = connectionProvider._address
@@ -1311,3 +1304,12 @@ describe('#integration session', () => {
13111304
})
13121305
}
13131306
})
1307+
1308+
function newSessionWithConnection (connection) {
1309+
const connectionProvider = new SingleConnectionProvider(
1310+
Promise.resolve(connection)
1311+
)
1312+
const session = new Session({ mode: READ, connectionProvider })
1313+
session.beginTransaction() // force session to acquire new connection
1314+
return session
1315+
}

0 commit comments

Comments
 (0)