Skip to content

Commit ffae61a

Browse files
committed
Close drivers after tests
1 parent 6510f92 commit ffae61a

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

test/internal/tls.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ describe('trust-system-ca-signed-certificates', function() {
172172
describe('trust-on-first-use', function() {
173173

174174
var driver;
175-
175+
afterEach(function(){
176+
if( driver ) {
177+
driver.close();
178+
}
179+
});
176180
it("should create known_hosts file including full path if it doesn't exist", function(done) {
177181
// Assuming we only run this test on NodeJS with TOFU support
178182
if( !hasFeature("trust_on_first_use") ) {
@@ -191,7 +195,7 @@ describe('trust-on-first-use', function() {
191195
fs.rmdirSync(knownHostsDir);
192196
} catch (_) { }
193197

194-
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j"), {
198+
driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j"), {
195199
encrypted: true,
196200
trust: "TRUST_ON_FIRST_USE",
197201
knownHosts: knownHostsPath

test/v1/driver.test.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@
2020
var neo4j = require("../../lib/v1");
2121

2222
describe('driver', function() {
23-
23+
var driver;
24+
beforeEach(function() {
25+
driver = null;
26+
})
27+
afterEach(function() {
28+
if(driver) {
29+
driver.close();
30+
}
31+
})
2432
it('should expose sessions', function() {
2533
// Given
26-
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j"));
34+
driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j"));
2735

2836
// When
2937
var session = driver.session();
@@ -35,7 +43,7 @@ describe('driver', function() {
3543

3644
it('should handle connection errors', function(done) {
3745
// Given
38-
var driver = neo4j.driver("bolt://localhoste", neo4j.auth.basic("neo4j", "neo4j"));
46+
driver = neo4j.driver("bolt://localhoste", neo4j.auth.basic("neo4j", "neo4j"));
3947

4048
// Expect
4149
driver.onError = function (err) {
@@ -54,7 +62,7 @@ describe('driver', function() {
5462

5563
it('should fail early on wrong credentials', function(done) {
5664
// Given
57-
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "who would use such a password"));
65+
driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "who would use such a password"));
5866

5967
// Expect
6068
driver.onError = function (err) {
@@ -69,7 +77,7 @@ describe('driver', function() {
6977

7078
it('should indicate success early on correct credentials', function(done) {
7179
// Given
72-
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j"));
80+
driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j"));
7381

7482
// Expect
7583
driver.onCompleted = function (meta) {
@@ -82,7 +90,7 @@ describe('driver', function() {
8290

8391
it('should be possible to pass a realm with basic auth tokens', function(done) {
8492
// Given
85-
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j", "native"));
93+
driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j", "native"));
8694

8795
// Expect
8896
driver.onCompleted = function (meta) {
@@ -95,7 +103,7 @@ describe('driver', function() {
95103

96104
it('should be possible to create custom auth tokens', function(done) {
97105
// Given
98-
var driver = neo4j.driver("bolt://localhost", neo4j.auth.custom("neo4j", "neo4j", "native", "basic"));
106+
driver = neo4j.driver("bolt://localhost", neo4j.auth.custom("neo4j", "neo4j", "native", "basic"));
99107

100108
// Expect
101109
driver.onCompleted = function (meta) {
@@ -108,7 +116,7 @@ describe('driver', function() {
108116

109117
it('should be possible to create custom auth tokens with additional parameters', function(done) {
110118
// Given
111-
var driver = neo4j.driver("bolt://localhost", neo4j.auth.custom("neo4j", "neo4j", "native", "basic", {secret: 42}));
119+
driver = neo4j.driver("bolt://localhost", neo4j.auth.custom("neo4j", "neo4j", "native", "basic", {secret: 42}));
112120

113121
// Expect
114122
driver.onCompleted = function () {
@@ -121,7 +129,7 @@ describe('driver', function() {
121129

122130
it('should fail nicely when connecting with routing to standalone server', function(done) {
123131
// Given
124-
var driver = neo4j.driver("bolt+routing://localhost", neo4j.auth.basic("neo4j", "neo4j"));
132+
driver = neo4j.driver("bolt+routing://localhost", neo4j.auth.basic("neo4j", "neo4j"));
125133

126134
// Expect
127135
driver.onError = function (err) {

0 commit comments

Comments
 (0)