@@ -20,11 +20,14 @@ module.exports = function () {
20
20
} ) ;
21
21
22
22
this . Then ( / ^ s e s s i o n s s h o u l d s i m p l y w o r k $ / , { timeout : CALLBACK_TIMEOUT } , function ( callback ) {
23
- var session = this . driver1 . session ( ) ;
23
+ var self = this ;
24
+ var session = self . driver1 . session ( ) ;
24
25
session . run ( "RETURN 1" ) . then ( function ( result ) {
25
26
session . close ( ) ;
27
+ _closeDrivers ( self . driver1 , self . driver2 ) ;
26
28
callback ( ) ;
27
29
} ) . catch ( function ( error ) {
30
+ _closeDrivers ( self . driver1 , self . driver2 ) ;
28
31
console . log ( error ) ;
29
32
} ) ;
30
33
} ) ;
@@ -57,11 +60,13 @@ module.exports = function () {
57
60
var self = this ;
58
61
session . run ( "RETURN 1" )
59
62
. then ( function ( res ) {
63
+ _closeDrivers ( self . driver1 , self . driver2 ) ;
60
64
console . log ( res ) ;
61
65
} )
62
66
. catch ( function ( error ) {
63
67
self . error = error ;
64
68
session . close ( ) ;
69
+ _closeDrivers ( self . driver1 , self . driver2 ) ;
65
70
callback ( ) ;
66
71
} ) ;
67
72
} ) ;
@@ -76,6 +81,9 @@ module.exports = function () {
76
81
"and the driver will update the file with the new certificate. You can configure which file the driver should use " +
77
82
"to store this information by setting `knownHosts` to another path in your driver configuration - " +
78
83
"and you can disable encryption there as well using `encrypted:\"ENCRYPTION_OFF\"`." ;
84
+
85
+ _closeDrivers ( this . driver1 , this . driver2 ) ;
86
+
79
87
if ( this . error . message !== expected ) {
80
88
callback ( new Error ( "Given and expected results does not match: " + this . error . message + " Expected " + expected ) ) ;
81
89
} else {
@@ -101,6 +109,7 @@ module.exports = function () {
101
109
var session2 = self . driver2 . session ( ) ;
102
110
session2 . run ( "RETURN 1" ) . then ( function ( result ) {
103
111
session2 . close ( ) ;
112
+ _closeDrivers ( self . driver1 , self . driver2 ) ;
104
113
callback ( ) ;
105
114
} ) ;
106
115
} ) ;
@@ -157,6 +166,9 @@ module.exports = function () {
157
166
"`neo4j.v1.driver(.., { trustedCertificates:['path/to/certificate.crt']}). This is a security measure to protect " +
158
167
"against man-in-the-middle attacks. If you are just trying Neo4j out and are not concerned about encryption, " +
159
168
"simply disable it using `encrypted=\"ENCRYPTION_OFF\"` in the driver options. Socket responded with: DEPTH_ZERO_SELF_SIGNED_CERT" ;
169
+
170
+ _closeDrivers ( this . driver1 , this . driver2 ) ;
171
+
160
172
if ( this . error . message !== expected ) {
161
173
callback ( new Error ( "Given and expected results does not match: " + this . error . message + " Expected " + expected ) ) ;
162
174
} else {
@@ -171,4 +183,13 @@ module.exports = function () {
171
183
encrypted : "ENCRYPTION_ON"
172
184
} ) ;
173
185
}
186
+
187
+ function _closeDrivers ( ) {
188
+ for ( var i = 0 ; i < arguments . length ; i ++ ) {
189
+ var driver = arguments [ i ] ;
190
+ if ( driver ) {
191
+ driver . close ( ) ;
192
+ }
193
+ }
194
+ }
174
195
} ;
0 commit comments