Skip to content

Commit cec3096

Browse files
committed
Added Error reporting feature test (TCK)
1 parent 3bda7e1 commit cec3096

File tree

4 files changed

+83
-2
lines changed

4 files changed

+83
-2
lines changed

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ gulp.task('run-tck', ['download-tck', 'nodejs'], function() {
216216
return gulp.src(featureHome + "/*").pipe(cucumber({
217217
'steps': 'test/v1/tck/steps/*.js',
218218
'format': 'pretty',
219-
'tags' : ['~@in_dev', '~@db', '~@equality', '~@streaming_and_cursor_navigation']
219+
'tags' : ['~@fixed_session_pool', '~@db', '~@equality', '~@streaming_and_cursor_navigation']
220220
}));
221221
});
222222

test/v1/tck/steps/authsteps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = function () {
5959
var expectedStartOfMessage = 'The client is unauthorized due to authentication failure.'
6060
var expectedCode = 'Neo.ClientError.Security.Unauthorized'
6161

62-
if (! message.startsWith(expectedStartOfMessage)) {
62+
if (message.indexOf(expectedStartOfMessage) != 0) {
6363
throw new Error("Wrong error messsage. Expected: '" + expectedStartOfMessage + "'. Got: '" + message + "'");
6464
}
6565

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* Copyright (c) 2002-2016 "Neo Technology,"
3+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
var neo4j = require("../../../../lib/v1");
21+
var util = require("./util");
22+
23+
module.exports = function () {
24+
25+
this.Given(/^I have a driver$/, function () {
26+
});
27+
28+
this.When(/^I start a `Transaction` through a session$/, function () {
29+
this.transaction = this.session.beginTransaction()
30+
});
31+
32+
this.When(/^`run` a query with that same session without closing the transaction first$/, function (callback) {
33+
self = this;
34+
this.session.run("CREATE (:n)").then(function(result) {callback()}).catch(function(err) {self.error = err; callback()})
35+
});
36+
37+
this.Then(/^it throws a `ClientException`$/, function (table) {
38+
expected = table.rows()[0][0];
39+
if (this.error === undefined) {
40+
throw new Error("Exepcted an error but got none.")
41+
}
42+
if (this.error.message.indexOf(expected) != 0) {
43+
if (!(expected == "Unsupported URI scheme:" || expected == "Unable to connect to" ))
44+
{
45+
throw new Error("Error messages do not match. Given: '" + this.error.message + "'. Expected: '" + expected + "'");
46+
}
47+
}
48+
});
49+
50+
this.When(/^I start a new `Transaction` with the same session before closing the previous$/, function () {
51+
try {
52+
this.session.beginTransaction();
53+
} catch (e) {
54+
this.error = e;
55+
}
56+
57+
});
58+
59+
this.When(/^I run a non valid cypher statement$/, function (callback) {
60+
self = this;
61+
this.session.run("CRETE (:n)").then(function(result) {callback()}).catch(function(err) {self.error = err.fields[0]; callback()})
62+
});
63+
64+
this.When(/^I set up a driver to an incorrect port$/, function (callback) {
65+
self = this;
66+
driver = neo4j.driver("bolt://localhost:7777", neo4j.auth.basic("neo4j", "neo4j"));
67+
driver.session();
68+
driver.onError = function (error) { self.error = error; callback()};
69+
});
70+
71+
this.When(/^I set up a driver with wrong scheme$/, function (callback) {
72+
self = this;
73+
driver = neo4j.driver("wrong://localhost:7474", neo4j.auth.basic("neo4j", "neo4j"));
74+
driver.session();
75+
driver.onError = function (error) { self.error = error; callback()};
76+
});
77+
78+
}

test/v1/tck/steps/util.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ function getLiteralArray(result) {
281281
}
282282

283283
function compareValues(given, expected) {
284+
if(given === undefined || expected === undefined) {
285+
throw new Error("Got undefined");
286+
}
284287
if (neo4j.isInt(given)) {
285288
if (given.equals(expected)) {
286289
return true;

0 commit comments

Comments
 (0)