From b7df6c1d5841dfe791dd8983e51fe67110dc12e4 Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Fri, 26 Jul 2019 09:49:19 +0200 Subject: [PATCH] add ad-hoc test method --- .gitignore | 1 + project.clj | 2 +- src/leiningen/neo4j.clj | 12 +++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c53038e..b52008d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ pom.xml.asc /.nrepl-port .hgignore .hg/ +*.iml diff --git a/project.clj b/project.clj index c1d6ba2..d37550f 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject joshavg/lein-neo4j "0.5.0" +(defproject joshavg/lein-neo4j "0.6.0" :description "neo4j server invokable from leiningen" :url "https://gitea.heevyis.ninja/josha/lein-neo4j" :license {:name "GPL-3.0" diff --git a/src/leiningen/neo4j.clj b/src/leiningen/neo4j.clj index dea78e3..5d8c39c 100644 --- a/src/leiningen/neo4j.clj +++ b/src/leiningen/neo4j.clj @@ -1,7 +1,5 @@ (ns leiningen.neo4j - (:import org.neo4j.graphdb.factory.GraphDatabaseFactory - org.neo4j.server.CommunityBootstrapper - java.lang.Runtime + (:import org.neo4j.server.CommunityBootstrapper java.lang.Thread java.util.Optional) (:require [clojure.java.io :as io])) @@ -13,3 +11,11 @@ server (CommunityBootstrapper.)] (.start server path (Optional/empty) config) (while true (Thread/sleep 5000)))) + +(defn with-db [& {:keys [path config do-with-db] + :or {:path "target/neo4j" + :config {}}}] + (let [server (CommunityBootstrapper.)] + (.start server path (Optional/empty) config) + (do-with-db) + (.stop server)))