Merge branch '0.1.11'
This commit is contained in:
commit
7fbb433e2f
7 changed files with 102 additions and 45 deletions
20
README.md
20
README.md
|
|
@ -274,7 +274,7 @@ Each "tool" has a single responsibility and can be composed with other tools in
|
||||||
* `only` will return _only_ states that it is given + exist (seen by mount) in the application
|
* `only` will return _only_ states that it is given + exist (seen by mount) in the application
|
||||||
* `except` will return all the states that it is given _except_ a given set
|
* `except` will return all the states that it is given _except_ a given set
|
||||||
* `swap` will take a map with keys as states and values as their substitute values
|
* `swap` will take a map with keys as states and values as their substitute values
|
||||||
* `swap-states` will take a map with keys as states and values as their substitute states
|
* `swap-states` will take a map with keys as states and values with `{:start fn :stop fn}` as their substitute states
|
||||||
* `with-args` will take a map that could later be accessed by `(mount/args)`
|
* `with-args` will take a map that could later be accessed by `(mount/args)`
|
||||||
|
|
||||||
All these functions take one or two arguments. If called with two arguments, the first one will be treated as the universe of states to work with. If called with one argument, it will work with _all known_ to mount states.
|
All these functions take one or two arguments. If called with two arguments, the first one will be treated as the universe of states to work with. If called with one argument, it will work with _all known_ to mount states.
|
||||||
|
|
@ -312,7 +312,8 @@ Here is a more "involved" example:
|
||||||
(with-args {:a 42})
|
(with-args {:a 42})
|
||||||
(except [#'foo/c
|
(except [#'foo/c
|
||||||
#'bar/d])
|
#'bar/d])
|
||||||
(swap-states {#'foo/a #'test/a})
|
(swap-states {#'foo/a {:start #(create-connection test-conf)
|
||||||
|
:stop #(disconnect a)}})
|
||||||
(swap {#'baz/e {:datomic {:uri "datomic:mem://composable-mount"}}})
|
(swap {#'baz/e {:datomic {:uri "datomic:mem://composable-mount"}}})
|
||||||
mount/start)
|
mount/start)
|
||||||
```
|
```
|
||||||
|
|
@ -381,14 +382,21 @@ When running tests it would be great _not_ to send the real text messages, but r
|
||||||
|
|
||||||
### Swapping States with States
|
### Swapping States with States
|
||||||
|
|
||||||
The `start-with-states` function takes other states as substitutes:
|
The `start-with-states` function takes values in a form of `{:start fn :stop fn}` as substitutes:
|
||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
(mount/start-with-states {#'app.neo/db #'app.test/test-db
|
(mount/start-with-states {#'app.neo/db {:start #(connect test-config)
|
||||||
#'app.neo/publisher #'app.test/test-publisher})
|
:stop #(disconnect db)}
|
||||||
|
#'app.neo/publisher {:start #(create-pub test-config)
|
||||||
|
:stop #(close-pub publisher)}})
|
||||||
```
|
```
|
||||||
|
|
||||||
`start-with-states` takes a map of states with their substitutes. For example `#'app.nyse/db` here is the real deal (remote) DB that is being substituted with `#'app.test/test-db` state, which could be anything, a map, an in memory DB, etc.
|
`start-with-states` takes a map of states with their substitutes. For example `#'app.nyse/db` here is the real deal (remote) DB that is being
|
||||||
|
substituted with `#(connect test-config)` function, which could endup being anything, a map, an in memory DB, etc.
|
||||||
|
|
||||||
|
The `:stop` functions of substitutes can be anything, and could refer to the original state references. As in the example above: `db` and `publisher`
|
||||||
|
are real references. They would need to be accessible from the namespace of course, so you might need to `(:require [app.neo :refer [db]])`
|
||||||
|
in order to use `db` in `:stop #(disconnect db)` example above.
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
||||||
|
|
|
||||||
12
build.boot
12
build.boot
|
|
@ -20,6 +20,10 @@
|
||||||
[org.clojure/tools.nrepl "0.2.12" :scope "provided"]
|
[org.clojure/tools.nrepl "0.2.12" :scope "provided"]
|
||||||
[com.datomic/datomic-free "0.9.5359" :scope "provided" :exclusions [joda-time]]
|
[com.datomic/datomic-free "0.9.5359" :scope "provided" :exclusions [joda-time]]
|
||||||
|
|
||||||
|
;; proto repl for fun and joy
|
||||||
|
[proto-repl "0.3.1" :scope "provided"]
|
||||||
|
[proto-repl-charts "0.3.2" :scope "provided"]
|
||||||
|
|
||||||
;; boot clj
|
;; boot clj
|
||||||
[boot/core "2.6.0" :scope "provided"]
|
[boot/core "2.6.0" :scope "provided"]
|
||||||
[adzerk/bootlaces "0.1.13" :scope "test"]
|
[adzerk/bootlaces "0.1.13" :scope "test"]
|
||||||
|
|
@ -62,7 +66,7 @@
|
||||||
(deftask dev []
|
(deftask dev []
|
||||||
(set-env! :source-paths #(conj % "dev/clj" "dev/cljs"))
|
(set-env! :source-paths #(conj % "dev/clj" "dev/cljs"))
|
||||||
|
|
||||||
(alter-var-root #'log/*logger-factory*
|
(alter-var-root #'log/*logger-factory*
|
||||||
(constantly (log-service/make-factory log4b)))
|
(constantly (log-service/make-factory log4b)))
|
||||||
(apply set-refresh-dirs (get-env :directories))
|
(apply set-refresh-dirs (get-env :directories))
|
||||||
(load-data-readers!)
|
(load-data-readers!)
|
||||||
|
|
@ -80,7 +84,7 @@
|
||||||
|
|
||||||
(require '[mount.core])
|
(require '[mount.core])
|
||||||
|
|
||||||
(comp
|
(comp
|
||||||
(strip-deps-attr :attr :classifier :value "aot")
|
(strip-deps-attr :attr :classifier :value "aot")
|
||||||
(tcs/test-cljs ;; :optimizations :advanced
|
(tcs/test-cljs ;; :optimizations :advanced
|
||||||
:out-file "mount.js")))
|
:out-file "mount.js")))
|
||||||
|
|
@ -88,7 +92,7 @@
|
||||||
(deftask test-cljs-advanced []
|
(deftask test-cljs-advanced []
|
||||||
(set-env! :source-paths #(conj % "dev/clj" "dev/cljs"))
|
(set-env! :source-paths #(conj % "dev/clj" "dev/cljs"))
|
||||||
(set-env! :resource-paths #{"dev/resources"})
|
(set-env! :resource-paths #{"dev/resources"})
|
||||||
|
|
||||||
(comp
|
(comp
|
||||||
(cljs :optimizations :advanced :ids #{"mount"})))
|
(cljs :optimizations :advanced :ids #{"mount"})))
|
||||||
|
|
||||||
|
|
@ -114,7 +118,7 @@
|
||||||
(cljs-repl)
|
(cljs-repl)
|
||||||
(cljs :optimizations :none :ids #{"mount"})))
|
(cljs :optimizations :none :ids #{"mount"})))
|
||||||
|
|
||||||
(deftask cljs-example
|
(deftask cljs-example
|
||||||
"mount cljs example"
|
"mount cljs example"
|
||||||
[]
|
[]
|
||||||
(set-env! :source-paths #(conj % "dev/clj" "dev/cljs"))
|
(set-env! :source-paths #(conj % "dev/clj" "dev/cljs"))
|
||||||
|
|
|
||||||
15
dev/clj/proto_play.clj
Normal file
15
dev/clj/proto_play.clj
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
(ns proto-play
|
||||||
|
(:require [mount.tools.graph :as mount]
|
||||||
|
[proto-repl-charts.graph :as proto]))
|
||||||
|
|
||||||
|
(defn mount->proto [graph]
|
||||||
|
(reduce (fn [g {:keys [name deps]}]
|
||||||
|
(-> g
|
||||||
|
(update :nodes conj name)
|
||||||
|
(update :edges conj (-> deps (conj name) vec))))
|
||||||
|
{}
|
||||||
|
graph))
|
||||||
|
|
||||||
|
(->> (mount/states-with-deps)
|
||||||
|
mount->proto
|
||||||
|
(proto/graph "a proto graph of mount states"))
|
||||||
|
|
@ -144,7 +144,7 @@
|
||||||
:status #{:stopped}}
|
:status #{:stopped}}
|
||||||
stop (assoc :stop `(fn [] ~stop)))]
|
stop (assoc :stop `(fn [] ~stop)))]
|
||||||
`(do
|
`(do
|
||||||
(log (str "|| mounting... " ~state-name))
|
;; (log (str "|| mounting... " ~state-name))
|
||||||
(~'defonce ~state (DerefableState. ~state-name))
|
(~'defonce ~state (DerefableState. ~state-name))
|
||||||
(mount-it (~'var ~state) ~state-name ~s-meta)
|
(mount-it (~'var ~state) ~state-name ~s-meta)
|
||||||
(~'var ~state))))))
|
(~'var ~state))))))
|
||||||
|
|
@ -167,7 +167,7 @@
|
||||||
;;TODO args might need more thinking
|
;;TODO args might need more thinking
|
||||||
(defn args [] @-args)
|
(defn args [] @-args)
|
||||||
|
|
||||||
(defn- find-all-states []
|
(defn find-all-states []
|
||||||
(keys @meta-state))
|
(keys @meta-state))
|
||||||
|
|
||||||
#?(:clj
|
#?(:clj
|
||||||
|
|
@ -182,7 +182,7 @@
|
||||||
v)))
|
v)))
|
||||||
|
|
||||||
(defn running-states []
|
(defn running-states []
|
||||||
(keys @running))
|
(set (keys @running)))
|
||||||
|
|
||||||
(defn- unvar-state [s]
|
(defn- unvar-state [s]
|
||||||
(->> s (drop 2) (apply str))) ;; magic 2 is removing "#'" in state name
|
(->> s (drop 2) (apply str))) ;; magic 2 is removing "#'" in state name
|
||||||
|
|
@ -231,9 +231,7 @@
|
||||||
origin (@meta-state state)
|
origin (@meta-state state)
|
||||||
sub (if (= :value mode)
|
sub (if (= :value mode)
|
||||||
{:start (fn [] with) :status :stopped}
|
{:start (fn [] with) :status :stopped}
|
||||||
(@meta-state with))]
|
(assoc with :status :stopped))]
|
||||||
(when (= :state mode)
|
|
||||||
(update-meta! [with :sub?] true))
|
|
||||||
(update-meta! [state] (merge-lifecycles origin (lifecycle-fns origin) sub))))
|
(update-meta! [state] (merge-lifecycles origin (lifecycle-fns origin) sub))))
|
||||||
|
|
||||||
(defn- unsub [state]
|
(defn- unsub [state]
|
||||||
|
|
@ -246,7 +244,7 @@
|
||||||
(defn start [& states]
|
(defn start [& states]
|
||||||
(let [fs (-> states first)]
|
(let [fs (-> states first)]
|
||||||
(if (coll? fs)
|
(if (coll? fs)
|
||||||
(if-not (empty? fs) ;; (mount/start) vs. (mount/start #{}) vs. (mount/start #{1 2 3})
|
(if-not (empty? fs) ;; (mount/start) vs. (mount/start #{}) vs. (mount/start #{1 2 3})
|
||||||
(apply start fs)
|
(apply start fs)
|
||||||
{:started #{}})
|
{:started #{}})
|
||||||
(let [states (or (seq states)
|
(let [states (or (seq states)
|
||||||
|
|
@ -254,11 +252,17 @@
|
||||||
{:started (bring states up <)}))))
|
{:started (bring states up <)}))))
|
||||||
|
|
||||||
(defn stop [& states]
|
(defn stop [& states]
|
||||||
(let [states (or states (find-all-states))
|
(let [fs (-> states first)]
|
||||||
_ (dorun (map unsub states)) ;; unmark substitutions marked by "start-with"
|
(if (coll? fs)
|
||||||
stopped (bring states down >)]
|
(if-not (empty? fs) ;; (mount/stop) vs. (mount/stop #{}) vs. (mount/stop #{1 2 3})
|
||||||
(dorun (map rollback! states)) ;; restore to origin from "start-with"
|
(apply stop fs)
|
||||||
{:stopped stopped}))
|
{:stopped #{}})
|
||||||
|
(let [states (or (seq states)
|
||||||
|
(find-all-states))
|
||||||
|
_ (dorun (map unsub states)) ;; unmark substitutions marked by "start-with" / "swap-states"
|
||||||
|
stopped (bring states down >)]
|
||||||
|
(dorun (map rollback! states)) ;; restore to origin from "start-with" / "swap-states"
|
||||||
|
{:stopped stopped}))))
|
||||||
|
|
||||||
;; composable set of states
|
;; composable set of states
|
||||||
|
|
||||||
|
|
@ -302,7 +306,7 @@
|
||||||
([states with]
|
([states with]
|
||||||
(doseq [[from to] with]
|
(doseq [[from to] with]
|
||||||
(substitute! (var-to-str from)
|
(substitute! (var-to-str from)
|
||||||
(var-to-str to) :state))
|
to :state))
|
||||||
states))
|
states))
|
||||||
|
|
||||||
;; restart on events
|
;; restart on events
|
||||||
|
|
@ -354,7 +358,7 @@
|
||||||
(defn start-with-states [with]
|
(defn start-with-states [with]
|
||||||
(doseq [[from to] with]
|
(doseq [[from to] with]
|
||||||
(substitute! (var-to-str from)
|
(substitute! (var-to-str from)
|
||||||
(var-to-str to) :state))
|
to :state))
|
||||||
(start))
|
(start))
|
||||||
|
|
||||||
(defn start-without [& states]
|
(defn start-without [& states]
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,3 @@
|
||||||
meta-with-ns)
|
meta-with-ns)
|
||||||
states)
|
states)
|
||||||
(sort-by :order)))))
|
(sort-by :order)))))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
[tapp.audit-log :refer [log]]]
|
[tapp.audit-log :refer [log]]]
|
||||||
:clj [[clojure.test :as t :refer [is are deftest testing use-fixtures]]
|
:clj [[clojure.test :as t :refer [is are deftest testing use-fixtures]]
|
||||||
[clojure.set :refer [intersection]]
|
[clojure.set :refer [intersection]]
|
||||||
|
[clojure.tools.nrepl.server :refer [start-server stop-server]]
|
||||||
[mount.core :as mount :refer [defstate only except swap swap-states with-args]]
|
[mount.core :as mount :refer [defstate only except swap swap-states with-args]]
|
||||||
[tapp.conf :refer [config]]
|
[tapp.conf :refer [config]]
|
||||||
[tapp.nyse :refer [conn]]
|
[tapp.nyse :refer [conn]]
|
||||||
|
|
@ -21,6 +22,12 @@
|
||||||
|
|
||||||
(defstate test-nrepl :start [])
|
(defstate test-nrepl :start [])
|
||||||
|
|
||||||
|
(def swap-conn {:start (fn [] 42)
|
||||||
|
:stop #(println "stopping test-conn-state")})
|
||||||
|
#?(:clj
|
||||||
|
(def swap-nrepl {:start #(start-server :bind "localhost" :port 3442)
|
||||||
|
:stop #(stop-server @nrepl)}))
|
||||||
|
|
||||||
#?(:clj
|
#?(:clj
|
||||||
(deftest only-states
|
(deftest only-states
|
||||||
|
|
||||||
|
|
@ -93,19 +100,19 @@
|
||||||
(deftest swap-states-with-states
|
(deftest swap-states-with-states
|
||||||
|
|
||||||
(testing "swap-states should swap states with states and return all mount states if none is given"
|
(testing "swap-states should swap states with states and return all mount states if none is given"
|
||||||
(let [states (swap-states {#'tapp.nyse/conn #'mount.test.composable-fns/test-conn
|
(let [states (swap-states {#'tapp.nyse/conn swap-conn
|
||||||
#'tapp.example/nrepl #'mount.test.composable-fns/test-nrepl})]
|
#'tapp.example/nrepl swap-nrepl})]
|
||||||
(is (= states (#'mount.core/find-all-states)))
|
(is (= states (#'mount.core/find-all-states)))
|
||||||
(mount/start)
|
(mount/start)
|
||||||
(is (map? (dval config)))
|
(is (map? (dval config)))
|
||||||
(is (vector? (dval nrepl)))
|
(is (instance? clojure.tools.nrepl.server.Server (dval nrepl)))
|
||||||
(is (= 42 (dval conn)))
|
(is (= 42 (dval conn)))
|
||||||
(mount/stop)))
|
(mount/stop)))
|
||||||
|
|
||||||
(testing "swap-states should swap states with states and return only states that it is given"
|
(testing "swap-states should swap states with states and return only states that it is given"
|
||||||
(let [t-states #{"#'is.not/here" #'mount.test.composable-fns/test-conn #'tapp.nyse/conn}
|
(let [t-states #{"#'is.not/here" #'mount.test.composable-fns/test-conn #'tapp.nyse/conn}
|
||||||
states (swap-states t-states {#'tapp.nyse/conn #'mount.test.composable-fns/test-conn
|
states (swap-states t-states {#'tapp.nyse/conn swap-conn
|
||||||
#'tapp.example/nrepl #'mount.test.composable-fns/test-nrepl})]
|
#'tapp.example/nrepl swap-nrepl})]
|
||||||
(is (= states t-states))
|
(is (= states t-states))
|
||||||
(apply mount/start states)
|
(apply mount/start states)
|
||||||
(is (instance? mount.core.NotStartedState (dval config)))
|
(is (instance? mount.core.NotStartedState (dval config)))
|
||||||
|
|
@ -127,14 +134,14 @@
|
||||||
(with-args {:a 42})
|
(with-args {:a 42})
|
||||||
(except [#'mount.test.composable-fns/test-nrepl
|
(except [#'mount.test.composable-fns/test-nrepl
|
||||||
#'mount.test.composable-fns/test-conn])
|
#'mount.test.composable-fns/test-conn])
|
||||||
(swap-states {#'tapp.example/nrepl #'mount.test.composable-fns/test-nrepl})
|
(swap-states {#'tapp.example/nrepl swap-nrepl})
|
||||||
(swap {#'tapp.conf/config {:datomic {:uri "datomic:mem://composable-mount"}}}))]
|
(swap {#'tapp.conf/config {:datomic {:uri "datomic:mem://composable-mount"}}}))]
|
||||||
(is (= #{"#'tapp.nyse/conn" "#'tapp.conf/config" "#'tapp.example/nrepl"} (set states)))
|
(is (= #{"#'tapp.nyse/conn" "#'tapp.conf/config" "#'tapp.example/nrepl"} (set states)))
|
||||||
(mount/start states)
|
(mount/start states)
|
||||||
(is (= {:a 42} (mount/args)))
|
(is (= {:a 42} (mount/args)))
|
||||||
(is (= {:datomic {:uri "datomic:mem://composable-mount"}} (dval config)))
|
(is (= {:datomic {:uri "datomic:mem://composable-mount"}} (dval config)))
|
||||||
(is (instance? datomic.peer.LocalConnection (dval conn)))
|
(is (instance? datomic.peer.LocalConnection (dval conn)))
|
||||||
(is (vector? (dval nrepl)))
|
(is (instance? clojure.tools.nrepl.server.Server (dval nrepl)))
|
||||||
(mount/stop)))
|
(mount/stop)))
|
||||||
|
|
||||||
(testing "should compose and start in a single composition"
|
(testing "should compose and start in a single composition"
|
||||||
|
|
@ -147,17 +154,27 @@
|
||||||
(with-args {:a 42})
|
(with-args {:a 42})
|
||||||
(except [#'mount.test.composable-fns/test-nrepl
|
(except [#'mount.test.composable-fns/test-nrepl
|
||||||
#'mount.test.composable-fns/test-conn])
|
#'mount.test.composable-fns/test-conn])
|
||||||
(swap-states {#'tapp.example/nrepl #'mount.test.composable-fns/test-nrepl})
|
(swap-states {#'tapp.example/nrepl swap-nrepl})
|
||||||
(swap {#'tapp.conf/config {:datomic {:uri "datomic:mem://composable-mount"}}})
|
(swap {#'tapp.conf/config {:datomic {:uri "datomic:mem://composable-mount"}}})
|
||||||
mount/start)
|
mount/start)
|
||||||
(is (= {:a 42} (mount/args)))
|
(is (= {:a 42} (mount/args)))
|
||||||
(is (= {:datomic {:uri "datomic:mem://composable-mount"}} (dval config)))
|
(is (= {:datomic {:uri "datomic:mem://composable-mount"}} (dval config)))
|
||||||
(is (instance? datomic.peer.LocalConnection (dval conn)))
|
(is (instance? datomic.peer.LocalConnection (dval conn)))
|
||||||
(is (vector? (dval nrepl)))
|
(is (instance? clojure.tools.nrepl.server.Server (dval nrepl)))
|
||||||
(mount/stop)))
|
(mount/stop)))
|
||||||
|
|
||||||
(testing "should not start anything on empty seq of states"
|
(testing "should not start anything on empty seq of states"
|
||||||
(let [scope #{}]
|
(let [scope #{}]
|
||||||
(is (= {:started #{}} (-> (only scope)
|
(is (= {:started #{}} (-> (only scope)
|
||||||
mount/start)))
|
mount/start)))
|
||||||
(mount/stop)))))
|
(mount/stop)))
|
||||||
|
|
||||||
|
(testing "should not stop anything on empty seq of states"
|
||||||
|
(let [scope #{}]
|
||||||
|
(mount/start)
|
||||||
|
(is (instance? datomic.peer.LocalConnection (dval conn)))
|
||||||
|
(is (= {:stopped #{}} (-> (only scope)
|
||||||
|
mount/stop)))
|
||||||
|
(is (instance? datomic.peer.LocalConnection (dval conn)))
|
||||||
|
(mount/stop)
|
||||||
|
(is (instance? mount.core.NotStartedState (dval conn)))))))
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
[tapp.audit-log :refer [log]]]
|
[tapp.audit-log :refer [log]]]
|
||||||
:clj [[clojure.test :as t :refer [is are deftest testing use-fixtures]]
|
:clj [[clojure.test :as t :refer [is are deftest testing use-fixtures]]
|
||||||
[mount.core :as mount :refer [defstate]]
|
[mount.core :as mount :refer [defstate]]
|
||||||
|
[clojure.tools.nrepl.server :refer [start-server stop-server]]
|
||||||
[tapp.conf :refer [config]]
|
[tapp.conf :refer [config]]
|
||||||
[tapp.nyse :refer [conn]]
|
[tapp.nyse :refer [conn]]
|
||||||
[tapp.example :refer [nrepl]]])
|
[tapp.example :refer [nrepl]]])
|
||||||
|
|
@ -19,20 +20,29 @@
|
||||||
|
|
||||||
(defstate test-nrepl :start [])
|
(defstate test-nrepl :start [])
|
||||||
|
|
||||||
|
(def swap-conn {:start (fn [] 42)
|
||||||
|
:stop #(println "stopping test-conn-state")})
|
||||||
|
#?(:clj
|
||||||
|
(def swap-nrepl {:start #(start-server :bind "localhost" :port 3442)
|
||||||
|
:stop #(stop-server @nrepl)})
|
||||||
|
:cljs
|
||||||
|
(def swap-nrepl {:start (fn [] :nrepl)
|
||||||
|
:stop (fn [] :stopped-nrepl)}))
|
||||||
|
|
||||||
#?(:cljs
|
#?(:cljs
|
||||||
(deftest start-with-states
|
(deftest start-with-states
|
||||||
|
|
||||||
(testing "should start with substitutes"
|
(testing "should start with substitutes"
|
||||||
(let [_ (mount/start-with-states {#'tapp.websockets/system-a #'mount.test.start-with-states/test-conn
|
(let [_ (mount/start-with-states {#'tapp.websockets/system-a swap-conn
|
||||||
#'mount.test.helper/helper #'mount.test.start-with-states/test-nrepl})]
|
#'mount.test.helper/helper swap-nrepl})]
|
||||||
(is (map? (dval config)))
|
(is (map? (dval config)))
|
||||||
(is (vector? (dval helper)))
|
(is (= (:nrepl (dval helper))))
|
||||||
(is (= (dval system-a) 42))
|
(is (= (dval system-a) 42))
|
||||||
(is (instance? datascript.db/DB @(dval log)))
|
(is (instance? datascript.db/DB @(dval log)))
|
||||||
(mount/stop)))
|
(mount/stop)))
|
||||||
|
|
||||||
(testing "should not start the substitute itself"
|
#_(testing "should not start the substitute itself" ;; was true when subbing with exsiting states
|
||||||
(let [_ (mount/start-with-states {#'tapp.websockets/system-a #'mount.test.start-with-states/test-conn})]
|
(let [_ (mount/start-with-states {#'tapp.websockets/system-a swap-conn})]
|
||||||
(is (instance? mount.core.NotStartedState (dval test-conn)))
|
(is (instance? mount.core.NotStartedState (dval test-conn)))
|
||||||
(is (= 42 (dval system-a)))
|
(is (= 42 (dval system-a)))
|
||||||
(mount/stop)))
|
(mount/stop)))
|
||||||
|
|
@ -62,15 +72,15 @@
|
||||||
(deftest start-with-states
|
(deftest start-with-states
|
||||||
|
|
||||||
(testing "should start with substitutes"
|
(testing "should start with substitutes"
|
||||||
(let [_ (mount/start-with-states {#'tapp.nyse/conn #'mount.test.start-with-states/test-conn
|
(let [_ (mount/start-with-states {#'tapp.nyse/conn swap-conn
|
||||||
#'tapp.example/nrepl #'mount.test.start-with-states/test-nrepl})]
|
#'tapp.example/nrepl swap-nrepl})]
|
||||||
(is (map? (dval config)))
|
(is (map? (dval config)))
|
||||||
(is (vector? (dval nrepl)))
|
(is (instance? clojure.tools.nrepl.server.Server (dval nrepl)))
|
||||||
(is (= (dval conn) 42))
|
(is (= (dval conn) 42))
|
||||||
(mount/stop)))
|
(mount/stop)))
|
||||||
|
|
||||||
(testing "should not start the substitute itself"
|
#_(testing "should not start the substitute itself" ;; was true when subbing with exsiting states
|
||||||
(let [_ (mount/start-with-states {#'tapp.nyse/conn #'mount.test.start-with-states/test-conn})]
|
(let [_ (mount/start-with-states {#'tapp.nyse/conn swap-conn})]
|
||||||
(is (instance? mount.core.NotStartedState (dval test-conn)))
|
(is (instance? mount.core.NotStartedState (dval test-conn)))
|
||||||
(is (= (dval conn) 42))
|
(is (= (dval conn) 42))
|
||||||
(mount/stop)))
|
(mount/stop)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue