Added javascript and java driver tests.

Reviewers: buda

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D438
This commit is contained in:
Matej Ferencevic
2017-06-09 09:28:18 +02:00
parent 532f38ca3f
commit 6308ec6a34
7 changed files with 147 additions and 1 deletions

17
tests/drivers/javascript/run.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
NODE=nodejs
NPM=npm
if ! which $NODE >/dev/null; then
echo "Please install Node.JS!"
exit 1
fi
if ! which $NPM >/dev/null; then
echo "Please install NPM!"
exit 1
fi
$NPM install neo4j-driver || exit 1
$NODE test.js || exit 1

View File

@@ -0,0 +1,36 @@
var neo4j = require('neo4j-driver').v1;
var driver = neo4j.driver("bolt://localhost:7687",
neo4j.auth.basic("neo4j", "1234"),
{ encrypted: 'ENCRYPTION_OFF' });
var session = driver.session();
function die() {
session.close();
driver.close();
process.exit(1);
}
function run_query(query, callback) {
var run = session.run(query, {});
run.then(callback).catch(function (error) {
console.log(error);
die();
});
}
run_query("MATCH (n) DETACH DELETE n", function (result) {
console.log("Database cleared.");
run_query("CREATE (alice: Person {name: 'Alice', age: 22})", function (result) {
console.log("Record created.");
run_query("MATCH (n) RETURN n", function (result) {
console.log("Record matched.");
var alice = result.records[0].get("n");
if(alice.labels[0] != "Person" || alice.properties["name"] != "Alice"){
console.log("Data doesn't match!");
die();
}
console.log("All ok!");
driver.close();
});
});
});