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:
17
tests/drivers/javascript/run.sh
Executable file
17
tests/drivers/javascript/run.sh
Executable 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
|
||||
36
tests/drivers/javascript/test.js
Normal file
36
tests/drivers/javascript/test.js
Normal 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();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user