2015-11-16 03:28:34 +00:00
|
|
|
(ns check.start-with-test
|
2015-11-17 05:09:45 +00:00
|
|
|
(:require [mount.core :as mount :refer [defstate]]
|
2015-11-16 03:28:34 +00:00
|
|
|
[app.config :refer [app-config]]
|
|
|
|
|
[app.nyse :refer [conn]]
|
|
|
|
|
[app :refer [nrepl]]
|
|
|
|
|
[clojure.test :refer :all]))
|
|
|
|
|
|
2015-11-27 17:48:35 +00:00
|
|
|
(defstate test-conn :start 42
|
|
|
|
|
:stop #(constantly 0))
|
2015-11-16 03:28:34 +00:00
|
|
|
|
2015-11-27 17:48:35 +00:00
|
|
|
(defstate test-nrepl :start vector)
|
2015-11-16 03:28:34 +00:00
|
|
|
|
|
|
|
|
(deftest start-with
|
|
|
|
|
|
|
|
|
|
(testing "should start with substitutes"
|
2015-11-17 05:09:45 +00:00
|
|
|
(let [_ (mount/start-with {#'app.nyse/conn #'check.start-with-test/test-conn
|
|
|
|
|
#'app/nrepl #'check.start-with-test/test-nrepl})]
|
2015-11-16 03:28:34 +00:00
|
|
|
(is (map? app-config))
|
|
|
|
|
(is (vector? nrepl))
|
|
|
|
|
(is (= conn 42))
|
|
|
|
|
(mount/stop)))
|
|
|
|
|
|
2015-11-21 16:23:24 +00:00
|
|
|
(testing "should not start the substitute itself"
|
|
|
|
|
(let [_ (mount/start-with {#'app.nyse/conn #'check.start-with-test/test-conn})]
|
|
|
|
|
(is (instance? mount.core.NotStartedState test-conn))
|
|
|
|
|
(is (= conn 42))
|
|
|
|
|
(mount/stop)))
|
|
|
|
|
|
2015-11-16 03:28:34 +00:00
|
|
|
(testing "should start normally after start-with"
|
2015-11-17 05:09:45 +00:00
|
|
|
(let [_ (mount/start)]
|
2015-11-16 03:28:34 +00:00
|
|
|
(is (map? app-config))
|
|
|
|
|
(is (instance? clojure.tools.nrepl.server.Server nrepl))
|
|
|
|
|
(is (instance? datomic.peer.LocalConnection conn))
|
2015-11-16 14:07:55 +00:00
|
|
|
(is (= test-conn 42))
|
|
|
|
|
(is (vector? test-nrepl))
|
|
|
|
|
(mount/stop)))
|
|
|
|
|
|
|
|
|
|
(testing "should start-without normally after start-with"
|
2015-11-17 05:09:45 +00:00
|
|
|
(let [_ (mount/start-without #'check.start-with-test/test-conn
|
|
|
|
|
#'check.start-with-test/test-nrepl)]
|
2015-11-16 14:07:55 +00:00
|
|
|
(is (map? app-config))
|
|
|
|
|
(is (instance? clojure.tools.nrepl.server.Server nrepl))
|
|
|
|
|
(is (instance? datomic.peer.LocalConnection conn))
|
2015-11-17 05:09:45 +00:00
|
|
|
(is (instance? mount.core.NotStartedState test-conn))
|
|
|
|
|
(is (instance? mount.core.NotStartedState test-nrepl))
|
2015-11-16 03:28:34 +00:00
|
|
|
(mount/stop))))
|