Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-20-2019 01:58 PM
Hi,
I have some CYPHER queries that are executed using neo4j-driver. Things works fine in real, but I want to also write unit tests for this class so all possible scenarios are verified. With mysql etc we can use use sqllite and let the queries run on it. Is there a lite version of neo4j db that we can spawn up for test and kill after use?
I don't want to mock all db and session objs, as those tests are pretty dummy and not really useful in case things change.
Thanks,
Solved! Go to Solution.
06-27-2019 09:12 AM
You can also put your queries into .cypher
files and use a linter like libcypher-parser to check that your queries are valid.
06-27-2019 08:45 AM
Do you want to test that they work as expected (i.e. return the proper items) or just that they execute? If the latter, I would say a docker container running neo4j with a small seed script would do the trick as it spins up relatively quickly, is lightweight, and will let you test that the responses are as expected.
06-27-2019 09:03 AM
yea the later "just that they execute" as the queries will almost be hardcoded with parameter that change. so they would be verified.
06-27-2019 09:09 AM
Yeah, a simple docker container would be the easiest way to go then - you wouldn't even need to seed the DB, just check that there is not an exception.
With python, this can be as simple as using a try...catch
and failing the test on any exception.
for QUERY in QUERIES:
try:
GRAPH.run(QUERY)
except:
print(f"{QUERY} failed")
06-27-2019 09:12 AM
You can also put your queries into .cypher
files and use a linter like libcypher-parser to check that your queries are valid.
All the sessions of the conference are now available online