#69: stop accepts collections of states
vs. an implicit all and varargs
This commit is contained in:
parent
e2ef7bba55
commit
62cb9dd516
2 changed files with 23 additions and 7 deletions
|
|
@ -252,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)]
|
||||||
|
(if (coll? fs)
|
||||||
|
(if-not (empty? fs) ;; (mount/start) vs. (mount/start #{}) vs. (mount/start #{1 2 3})
|
||||||
|
(apply stop fs)
|
||||||
|
{:stopped #{}})
|
||||||
|
(let [states (or (seq states)
|
||||||
|
(find-all-states))
|
||||||
_ (dorun (map unsub states)) ;; unmark substitutions marked by "start-with"
|
_ (dorun (map unsub states)) ;; unmark substitutions marked by "start-with"
|
||||||
stopped (bring states down >)]
|
stopped (bring states down >)]
|
||||||
(dorun (map rollback! states)) ;; restore to origin from "start-with"
|
(dorun (map rollback! states)) ;; restore to origin from "start-with"
|
||||||
{:stopped stopped}))
|
{:stopped stopped}))))
|
||||||
|
|
||||||
;; composable set of states
|
;; composable set of states
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -167,4 +167,14 @@
|
||||||
(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)))))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue