From 421f5712fde4c38d048f8e783b447b20f9857db9 Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Fri, 26 Jul 2019 10:49:01 +0200 Subject: [PATCH] test impermanent database --- project.clj | 7 ++++--- src/leiningen/neo4j.clj | 13 ++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/project.clj b/project.clj index d37550f..234f34d 100644 --- a/project.clj +++ b/project.clj @@ -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" :url "https://gitea.heevyis.ninja/josha/lein-neo4j" :license {:name "GPL-3.0" :url "https://opensource.org/licenses/GPL-3.0"} :dependencies [[org.clojure/clojure "1.10.0"] - [org.neo4j/neo4j "3.5.3"] - [org.neo4j.app/neo4j-server "3.5.3"]] + [org.neo4j/neo4j "3.5.8"] + [org.neo4j.app/neo4j-server "3.5.8"] + [org.neo4j.community/it-test-support "3.5.8"]] :eval-in-leiningen true) diff --git a/src/leiningen/neo4j.clj b/src/leiningen/neo4j.clj index 5d8c39c..593c5ed 100644 --- a/src/leiningen/neo4j.clj +++ b/src/leiningen/neo4j.clj @@ -1,5 +1,6 @@ (ns leiningen.neo4j (:import org.neo4j.server.CommunityBootstrapper + org.neo4j.test.TestGraphDatabaseFactory java.lang.Thread java.util.Optional) (:require [clojure.java.io :as io])) @@ -12,10 +13,8 @@ (.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))) +(defn with-test-db [path do-with-db] + (let [db (.newImpermanentDatabase + (TestGraphDatabaseFactory.) + (io/as-file path))] + (do-with-db)))