mount/test/check/start_with_test.clj

48 lines
1.7 KiB
Clojure
Raw Normal View History

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]))
(defstate test-conn :start 42
:stop #(constantly 0))
2015-11-16 03:28:34 +00:00
(defstate test-nrepl :start [])
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))
(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)]
(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))))