test impermanent database

master
Josha von Gizycki 5 years ago
parent b7df6c1d58
commit 421f5712fd

@ -1,9 +1,10 @@
(defproject joshavg/lein-neo4j "0.6.0" (defproject joshavg/lein-neo4j "0.6.0-SNAPSHOT"
:description "neo4j server invokable from leiningen" :description "neo4j server invokable from leiningen"
:url "https://gitea.heevyis.ninja/josha/lein-neo4j" :url "https://gitea.heevyis.ninja/josha/lein-neo4j"
:license {:name "GPL-3.0" :license {:name "GPL-3.0"
:url "https://opensource.org/licenses/GPL-3.0"} :url "https://opensource.org/licenses/GPL-3.0"}
:dependencies [[org.clojure/clojure "1.10.0"] :dependencies [[org.clojure/clojure "1.10.0"]
[org.neo4j/neo4j "3.5.3"] [org.neo4j/neo4j "3.5.8"]
[org.neo4j.app/neo4j-server "3.5.3"]] [org.neo4j.app/neo4j-server "3.5.8"]
[org.neo4j.community/it-test-support "3.5.8"]]
:eval-in-leiningen true) :eval-in-leiningen true)

@ -1,5 +1,6 @@
(ns leiningen.neo4j (ns leiningen.neo4j
(:import org.neo4j.server.CommunityBootstrapper (:import org.neo4j.server.CommunityBootstrapper
org.neo4j.test.TestGraphDatabaseFactory
java.lang.Thread java.lang.Thread
java.util.Optional) java.util.Optional)
(:require [clojure.java.io :as io])) (:require [clojure.java.io :as io]))
@ -12,10 +13,8 @@
(.start server path (Optional/empty) config) (.start server path (Optional/empty) config)
(while true (Thread/sleep 5000)))) (while true (Thread/sleep 5000))))
(defn with-db [& {:keys [path config do-with-db] (defn with-test-db [path do-with-db]
:or {:path "target/neo4j" (let [db (.newImpermanentDatabase
:config {}}}] (TestGraphDatabaseFactory.)
(let [server (CommunityBootstrapper.)] (io/as-file path))]
(.start server path (Optional/empty) config) (do-with-db)))
(do-with-db)
(.stop server)))

Loading…
Cancel
Save