tests/neo4j: clear the potential existing elements before starting the tests
authorJean Privat <jean@pryen.org>
Thu, 15 Jun 2017 13:16:43 +0000 (09:16 -0400)
committerJean Privat <jean@pryen.org>
Thu, 15 Jun 2017 13:16:43 +0000 (09:16 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/test_neo4j.nit
tests/test_neo4j_batch.nit

index e556349..16038e9 100644 (file)
@@ -14,6 +14,7 @@
 
 import neo4j
 
+# key used to loosely assume unicity and prevent conflicting db accesses
 var key = "NIT_TESTING_ID".environ.to_i
 
 var srv = new Neo4jServer
@@ -24,6 +25,9 @@ print "# Test local\n"
 var client = new Neo4jClient("http://localhost:7474")
 assert client.is_ok
 
+# Clear the previous objects, if any
+client.cypher(new CypherQuery.from_string("MATCH (n) WHERE n.key = {key} OPTIONAL MATCH n-[r]-() DELETE r, n"))
+
 var andres = new NeoNode
 andres.labels.add_all(["PERSON", "MALE"])
 andres["name"] = "Andres"
index 35f550c..e098357 100644 (file)
@@ -17,6 +17,7 @@ import neo4j
 var srv = new Neo4jServer
 srv.start_quiet
 
+# key used to loosely assume unicity and prevent conflicting db accesses
 var key = "NIT_TESTING_ID".environ.to_i
 
 var andres = new NeoNode
@@ -39,6 +40,9 @@ loves["since"] = 1999
 var client = new Neo4jClient("http://localhost:7474")
 assert client.is_ok
 
+# Clear the previous objects, if any
+client.cypher(new CypherQuery.from_string("MATCH (n) WHERE n.key = {key} OPTIONAL MATCH n-[r]-() DELETE r, n"))
+
 print "# Save batch\n"
 
 var batch = new NeoBatch(client)