reorging sample clj/cljs apps. ready for cljs tests

This commit is contained in:
anatoly 2015-12-07 19:50:03 -05:00
parent 61f54cf12a
commit 8e34001122
25 changed files with 112 additions and 113 deletions

View file

@ -1,4 +1,4 @@
(ns app.config (ns app.conf
(:require [mount.core :as mount :refer [defstate]] (:require [mount.core :as mount :refer [defstate]]
[clojure.edn :as edn] [clojure.edn :as edn]
[clojure.tools.logging :refer [info]])) [clojure.tools.logging :refer [info]]))
@ -9,5 +9,5 @@
slurp slurp
edn/read-string)) edn/read-string))
(defstate app-config (defstate config
:start (load-config "test/resources/config.edn")) :start (load-config "dev/resources/config.edn"))

View file

@ -1,9 +1,9 @@
(ns app (ns app.example
(:require [datomic.api :as d] (:require [datomic.api :as d]
[clojure.tools.nrepl.server :refer [start-server stop-server]] [clojure.tools.nrepl.server :refer [start-server stop-server]]
[mount.core :as mount :refer [defstate]] [mount.core :as mount :refer [defstate]]
[app.utils.datomic :refer [touch]] [app.utils.datomic :refer [touch]]
[app.config :refer [app-config]] [app.conf :refer [config]]
[app.nyse :as nyse])) [app.nyse :as nyse]))
;; example on creating a network REPL ;; example on creating a network REPL
@ -11,7 +11,7 @@
(start-server :bind host :port port)) (start-server :bind host :port port))
;; nREPL is just another simple state ;; nREPL is just another simple state
(defstate nrepl :start (start-nrepl (:nrepl app-config)) (defstate nrepl :start (start-nrepl (:nrepl config))
:stop (stop-server nrepl)) :stop (stop-server nrepl))
;; datomic schema ;; datomic schema

View file

@ -2,7 +2,7 @@
(:require [mount.core :as mount :refer [defstate]] (:require [mount.core :as mount :refer [defstate]]
[datomic.api :as d] [datomic.api :as d]
[clojure.tools.logging :refer [info]] [clojure.tools.logging :refer [info]]
[app.config :refer [app-config]])) [app.conf :refer [config]]))
(defn- new-connection [conf] (defn- new-connection [conf]
(info "conf: " conf) (info "conf: " conf)
@ -17,5 +17,5 @@
(.release conn) ;; usually it's not released, here just to illustrate the access to connection on (stop) (.release conn) ;; usually it's not released, here just to illustrate the access to connection on (stop)
(d/delete-database uri))) (d/delete-database uri)))
(defstate conn :start (new-connection app-config) (defstate conn :start (new-connection config)
:stop (disconnect app-config conn)) :stop (disconnect config conn))

View file

@ -1,4 +1,4 @@
(ns mount.example.audit-log (ns app.audit-log
(:require [datascript.core :as d] (:require [datascript.core :as d]
[cljs-time.core :refer [now]]) [cljs-time.core :refer [now]])
(:require-macros [mount.core :refer [defstate]])) (:require-macros [mount.core :refer [defstate]]))

View file

@ -1,9 +1,9 @@
(ns mount.example.app-config (ns app.conf
(:require [mount.example.audit-log :refer [audit log]]) (:require [app.audit-log :refer [audit log]])
(:require-macros [mount.core :refer [defstate]])) (:require-macros [mount.core :refer [defstate]]))
(defn load-config [path] (defn load-config [path]
(audit log :app-config "loading config from '" path "' (at least pretending)") (audit log :app-conf "loading config from '" path "' (at least pretending)")
{:system-a {:uri "ws://echo.websocket.org/"}}) {:system-a {:uri "ws://echo.websocket.org/"}})
(defstate config :start (load-config "resources/config.end")) (defstate config :start (load-config "resources/config.end"))

View file

@ -1,8 +1,8 @@
(ns mount.example.app (ns app.example
(:require [mount.core :as mount] (:require [mount.core :as mount]
[mount.example.app-config] [app.conf]
[mount.example.websockets] [app.websockets]
[mount.example.audit-log :refer [log find-all-logs]] [app.audit-log :refer [log find-all-logs]]
[cljs-time.format :refer [unparse formatters]] [cljs-time.format :refer [unparse formatters]]
[hiccups.runtime :as hiccupsrt]) [hiccups.runtime :as hiccupsrt])
(:require-macros [hiccups.core :as hiccups :refer [html]])) (:require-macros [hiccups.core :as hiccups :refer [html]]))
@ -19,7 +19,7 @@
(mount/start) (mount/start)
;; time to establish a websocket connection before disconnecting ;; time to establish a websocket connection before disconnecting
(js/setTimeout #(mount/stop-except "#'mount.example.audit-log/log") 500) (js/setTimeout #(mount/stop-except "#'app.audit-log/log") 500)
;; time to close a connection to show it in audit ;; time to close a connection to show it in audit
(js/setTimeout #(show-log) 1000) (js/setTimeout #(show-log) 1000)

View file

@ -1,6 +1,6 @@
(ns mount.example.websockets (ns app.websockets
(:require [mount.example.app-config :refer [config]] (:require [app.conf :refer [config]]
[mount.example.audit-log :refer [audit log]]) [app.audit-log :refer [audit log]])
(:require-macros [mount.core :refer [defstate]])) (:require-macros [mount.core :refer [defstate]]))
(defn ws-status [ws] (defn ws-status [ws]

View file

@ -10,18 +10,15 @@
[clojure.string :as str] [clojure.string :as str]
[clojure.test :as test] [clojure.test :as test]
[clojure.tools.namespace.repl :as tn] [clojure.tools.namespace.repl :as tn]
[check.parts-test]
[check.start-with-test]
[check.suspend-resume-test]
[mount.core :as mount] [mount.core :as mount]
[app.utils.logging :refer [with-logging-status]] [app.utils.logging :refer [with-logging-status]]
[app :refer [create-nyse-schema find-orders add-order]])) ;; <<<< replace this your "app" namespace(s) you want to be available at REPL time [app.example :refer [create-nyse-schema find-orders add-order]])) ;; <<<< replace this your "app" namespace(s) you want to be available at REPL time
(defn start [] (defn start []
(with-logging-status) (with-logging-status)
(mount/start #'app.config/app-config (mount/start #'app.conf/config
#'app.nyse/conn #'app.nyse/conn
#'app/nrepl)) ;; example on how to start app with certain states #'app.example/nrepl)) ;; example on how to start app with certain states
(defn stop [] (defn stop []
(mount/stop)) (mount/stop))

View file

@ -9,7 +9,7 @@
:dependencies [[org.clojure/clojure "1.7.0"] :dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.170"]] [org.clojure/clojurescript "1.7.170"]]
:profiles {:dev {:source-paths ["dev" "test/app"] :profiles {:dev {:source-paths ["dev" "dev/clj" "test/clj"]
:dependencies [[datascript "0.13.3"] :dependencies [[datascript "0.13.3"]
[hiccups "0.3.0"] [hiccups "0.3.0"]
[com.andrewmcveigh/cljs-time "0.3.14"] [com.andrewmcveigh/cljs-time "0.3.14"]
@ -28,18 +28,18 @@
[:cljsbuild :builds :prod :compiler :output-to]] [:cljsbuild :builds :prod :compiler :output-to]]
:cljsbuild { :cljsbuild {
:builds {:dev :builds {:dev
{:source-paths ["src" "test"] {:source-paths ["dev/cljs" "test/cljs"]
:figwheel true :figwheel true
:compiler {:main mount.example.app :compiler {:main app.example
:asset-path "js/compiled/out" :asset-path "js/compiled/out"
:output-to "dev-resources/public/js/compiled/mount.js" :output-to "dev/resources/public/js/compiled/mount.js"
:output-dir "dev-resources/public/js/compiled/out" :output-dir "dev/resources/public/js/compiled/out"
:optimizations :none :optimizations :none
:source-map true :source-map true
:source-map-timestamp true}} :source-map-timestamp true}}
:prod :prod
{:source-paths ["src" "test"] {:source-paths ["src" "test"]
:compiler {:output-to "dev-resources/public/js/compiled/mount.js" :compiler {:output-to "dev/resources/public/js/compiled/mount.js"
:optimizations :advanced :optimizations :advanced
:pretty-print false}}}}}}) :pretty-print false}}}}}})

View file

@ -1,13 +0,0 @@
(ns check.cleanup_dirty_states_test
(:require [mount.core :as mount]
[app]
[clojure.test :refer :all]))
(deftest cleanup-dirty-states
(let [_ (mount/start)]
(is (not (.isClosed (:server-socket app/nrepl))))
(require 'app :reload)
(mount/start) ;; should not result in "BindException Address already in use" since the clean up will stop the previous instance
(is (not (.isClosed (:server-socket app/nrepl))))
(mount/stop)
(is (instance? mount.core.NotStartedState app/nrepl))))

View file

@ -0,0 +1,13 @@
(ns mount.cleanup_dirty_states_test
(:require [mount.core :as mount]
[app.example]
[clojure.test :refer :all]))
(deftest cleanup-dirty-states
(let [_ (mount/start)]
(is (not (.isClosed (:server-socket app.example/nrepl))))
(require 'app.example :reload)
(mount/start) ;; should not result in "BindException Address already in use" since the clean up will stop the previous instance
(is (not (.isClosed (:server-socket app.example/nrepl))))
(mount/stop)
(is (instance? mount.core.NotStartedState app.example/nrepl))))

View file

@ -1,4 +1,4 @@
(ns check.deref.fun-with-values-test (ns mount.deref.fun-with-values-test
(:require [mount.core :as mount :refer [defstate]] (:require [mount.core :as mount :refer [defstate]]
[clojure.test :refer :all])) [clojure.test :refer :all]))
@ -28,17 +28,17 @@
(defn with-fun-and-values [f] (defn with-fun-and-values [f]
(mount/in-cljc-mode) (mount/in-cljc-mode)
(require :reload 'check.deref.fun-with-values-test) (require :reload 'mount.deref.fun-with-values-test)
(mount/start #'check.deref.fun-with-values-test/scalar (mount/start #'mount.deref.fun-with-values-test/scalar
#'check.deref.fun-with-values-test/fun #'mount.deref.fun-with-values-test/fun
#'check.deref.fun-with-values-test/with-fun #'mount.deref.fun-with-values-test/with-fun
#'check.deref.fun-with-values-test/with-partial #'mount.deref.fun-with-values-test/with-partial
#'check.deref.fun-with-values-test/f-in-f #'mount.deref.fun-with-values-test/f-in-f
#'check.deref.fun-with-values-test/f-args #'mount.deref.fun-with-values-test/f-args
#'check.deref.fun-with-values-test/f-no-args-value #'mount.deref.fun-with-values-test/f-no-args-value
#'check.deref.fun-with-values-test/f-no-args #'mount.deref.fun-with-values-test/f-no-args
#'check.deref.fun-with-values-test/private-f #'mount.deref.fun-with-values-test/private-f
#'check.deref.fun-with-values-test/f-value) #'mount.deref.fun-with-values-test/f-value)
(f) (f)
(mount/stop) (mount/stop)
(mount/in-clj-mode)) (mount/in-clj-mode))

View file

@ -1,11 +1,11 @@
(ns check.deref.private-fun-test (ns mount.deref.private-fun-test
(:require [mount.core :as mount :refer [defstate]] (:require [mount.core :as mount :refer [defstate]]
[check.deref.fun-with-values-test :refer [private-f]] [mount.deref.fun-with-values-test :refer [private-f]]
[clojure.test :refer :all])) [clojure.test :refer :all]))
(defn with-fun-and-values [f] (defn with-fun-and-values [f]
(mount/in-cljc-mode) (mount/in-cljc-mode)
(mount/start #'check.deref.fun-with-values-test/private-f) (mount/start #'mount.deref.fun-with-values-test/private-f)
(f) (f)
(mount/stop) (mount/stop)
(mount/in-clj-mode)) (mount/in-clj-mode))

View file

@ -1,4 +1,4 @@
(ns check.fun-with-values-test (ns mount.fun-with-values-test
(:require [mount.core :as mount :refer [defstate]] (:require [mount.core :as mount :refer [defstate]]
[clojure.test :refer :all])) [clojure.test :refer :all]))
@ -27,16 +27,16 @@
(defstate private-f :start pf) (defstate private-f :start pf)
(defn with-fun-and-values [f] (defn with-fun-and-values [f]
(mount/start #'check.fun-with-values-test/scalar (mount/start #'mount.fun-with-values-test/scalar
#'check.fun-with-values-test/fun #'mount.fun-with-values-test/fun
#'check.fun-with-values-test/with-fun #'mount.fun-with-values-test/with-fun
#'check.fun-with-values-test/with-partial #'mount.fun-with-values-test/with-partial
#'check.fun-with-values-test/f-in-f #'mount.fun-with-values-test/f-in-f
#'check.fun-with-values-test/f-args #'mount.fun-with-values-test/f-args
#'check.fun-with-values-test/f-no-args-value #'mount.fun-with-values-test/f-no-args-value
#'check.fun-with-values-test/f-no-args #'mount.fun-with-values-test/f-no-args
#'check.fun-with-values-test/private-f #'mount.fun-with-values-test/private-f
#'check.fun-with-values-test/f-value) #'mount.fun-with-values-test/f-value)
(f) (f)
(mount/stop)) (mount/stop))

View file

@ -1,4 +1,4 @@
(ns check.parts-test (ns mount.parts-test
(:require [mount.core :as mount :refer [defstate] :as m] (:require [mount.core :as mount :refer [defstate] :as m]
[app.nyse :refer [conn]] [app.nyse :refer [conn]]
[clojure.test :refer :all])) [clojure.test :refer :all]))
@ -6,7 +6,7 @@
(defstate should-not-start :start #(constantly 42)) (defstate should-not-start :start #(constantly 42))
(defn with-parts [f] (defn with-parts [f]
(m/start #'app.config/app-config #'app.nyse/conn) (m/start #'app.conf/config #'app.nyse/conn)
(f) (f)
(m/stop)) (m/stop))

View file

@ -1,10 +1,10 @@
(ns check.private-fun-test (ns mount.private-fun-test
(:require [mount.core :as mount :refer [defstate]] (:require [mount.core :as mount :refer [defstate]]
[check.fun-with-values-test :refer [private-f]] [mount.fun-with-values-test :refer [private-f]]
[clojure.test :refer :all])) [clojure.test :refer :all]))
(defn with-fun-and-values [f] (defn with-fun-and-values [f]
(mount/start #'check.fun-with-values-test/private-f) (mount/start #'mount.fun-with-values-test/private-f)
(f) (f)
(mount/stop)) (mount/stop))

View file

@ -1,8 +1,8 @@
(ns check.start-with-test (ns mount.start-with-test
(:require [mount.core :as mount :refer [defstate]] (:require [mount.core :as mount :refer [defstate]]
[app.config :refer [app-config]] [app.conf :refer [config]]
[app.nyse :refer [conn]] [app.nyse :refer [conn]]
[app :refer [nrepl]] [app.example :refer [nrepl]]
[clojure.test :refer :all])) [clojure.test :refer :all]))
(defstate test-conn :start 42 (defstate test-conn :start 42
@ -13,22 +13,22 @@
(deftest start-with (deftest start-with
(testing "should start with substitutes" (testing "should start with substitutes"
(let [_ (mount/start-with {#'app.nyse/conn #'check.start-with-test/test-conn (let [_ (mount/start-with {#'app.nyse/conn #'mount.start-with-test/test-conn
#'app/nrepl #'check.start-with-test/test-nrepl})] #'app.example/nrepl #'mount.start-with-test/test-nrepl})]
(is (map? app-config)) (is (map? config))
(is (vector? nrepl)) (is (vector? nrepl))
(is (= conn 42)) (is (= conn 42))
(mount/stop))) (mount/stop)))
(testing "should not start the substitute itself" (testing "should not start the substitute itself"
(let [_ (mount/start-with {#'app.nyse/conn #'check.start-with-test/test-conn})] (let [_ (mount/start-with {#'app.nyse/conn #'mount.start-with-test/test-conn})]
(is (instance? mount.core.NotStartedState test-conn)) (is (instance? mount.core.NotStartedState test-conn))
(is (= conn 42)) (is (= conn 42))
(mount/stop))) (mount/stop)))
(testing "should start normally after start-with" (testing "should start normally after start-with"
(let [_ (mount/start)] (let [_ (mount/start)]
(is (map? app-config)) (is (map? config))
(is (instance? clojure.tools.nrepl.server.Server nrepl)) (is (instance? clojure.tools.nrepl.server.Server nrepl))
(is (instance? datomic.peer.LocalConnection conn)) (is (instance? datomic.peer.LocalConnection conn))
(is (= test-conn 42)) (is (= test-conn 42))
@ -36,9 +36,9 @@
(mount/stop))) (mount/stop)))
(testing "should start-without normally after start-with" (testing "should start-without normally after start-with"
(let [_ (mount/start-without #'check.start-with-test/test-conn (let [_ (mount/start-without #'mount.start-with-test/test-conn
#'check.start-with-test/test-nrepl)] #'mount.start-with-test/test-nrepl)]
(is (map? app-config)) (is (map? config))
(is (instance? clojure.tools.nrepl.server.Server nrepl)) (is (instance? clojure.tools.nrepl.server.Server nrepl))
(is (instance? datomic.peer.LocalConnection conn)) (is (instance? datomic.peer.LocalConnection conn))
(is (instance? mount.core.NotStartedState test-conn)) (is (instance? mount.core.NotStartedState test-conn))

View file

@ -1,18 +1,18 @@
(ns check.start-without-test (ns mount.start-without-test
(:require [mount.core :as m] (:require [mount.core :as m]
[app.config :refer [app-config]] [app.conf :refer [config]]
[app.nyse :refer [conn]] [app.nyse :refer [conn]]
[app :refer [nrepl]] [app.example :refer [nrepl]]
[clojure.test :refer :all])) [clojure.test :refer :all]))
(defn without [f] (defn without [f]
(m/start-without #'app.nyse/conn #'app/nrepl) (m/start-without #'app.nyse/conn #'app.example/nrepl)
(f) (f)
(m/stop)) (m/stop))
(use-fixtures :each without) (use-fixtures :each without)
(deftest start-without-states (deftest start-without-states
(is (map? app-config)) (is (map? config))
(is (instance? mount.core.NotStartedState nrepl)) (is (instance? mount.core.NotStartedState nrepl))
(is (instance? mount.core.NotStartedState conn))) (is (instance? mount.core.NotStartedState conn)))

View file

@ -1,31 +1,31 @@
(ns check.stop-except-test (ns mount.stop-except-test
(:require [mount.core :as mount :refer [defstate]] (:require [mount.core :as mount :refer [defstate]]
[app.config :refer [app-config]] [app.conf :refer [config]]
[app.nyse :refer [conn]] [app.nyse :refer [conn]]
[app :refer [nrepl]] [app.example :refer [nrepl]]
[clojure.test :refer :all])) [clojure.test :refer :all]))
(deftest stop-except (deftest stop-except
(testing "should stop all except nrepl" (testing "should stop all except nrepl"
(let [_ (mount/start) (let [_ (mount/start)
_ (mount/stop-except #'app.nyse/conn #'app.config/app-config)] _ (mount/stop-except #'app.nyse/conn #'app.conf/config)]
(is (map? app-config)) (is (map? config))
(is (instance? datomic.peer.LocalConnection conn)) (is (instance? datomic.peer.LocalConnection conn))
(is (instance? mount.core.NotStartedState nrepl)) (is (instance? mount.core.NotStartedState nrepl))
(mount/stop))) (mount/stop)))
(testing "should start normally after stop-except" (testing "should start normally after stop-except"
(let [_ (mount/start)] (let [_ (mount/start)]
(is (map? app-config)) (is (map? config))
(is (instance? clojure.tools.nrepl.server.Server nrepl)) (is (instance? clojure.tools.nrepl.server.Server nrepl))
(is (instance? datomic.peer.LocalConnection conn)) (is (instance? datomic.peer.LocalConnection conn))
(mount/stop))) (mount/stop)))
(testing "should stop all normally after stop-except" (testing "should stop all normally after stop-except"
(let [_ (mount/start) (let [_ (mount/start)
_ (mount/stop-except #'app.nyse/conn #'app.config/app-config) _ (mount/stop-except #'app.nyse/conn #'app.conf/config)
_ (mount/stop)] _ (mount/stop)]
(is (instance? mount.core.NotStartedState app-config)) (is (instance? mount.core.NotStartedState config))
(is (instance? mount.core.NotStartedState conn)) (is (instance? mount.core.NotStartedState conn))
(is (instance? mount.core.NotStartedState nrepl))))) (is (instance? mount.core.NotStartedState nrepl)))))

View file

@ -1,8 +1,8 @@
(ns check.suspend-resume-test (ns mount.suspend-resume-test
(:require [mount.core :as mount :refer [defstate]] (:require [mount.core :as mount :refer [defstate]]
[app.config :refer [app-config]] [app.conf :refer [config]]
[app.nyse :refer [conn]] [app.nyse :refer [conn]]
[app :refer [nrepl]] [app.example :refer [nrepl]]
[clojure.test :refer :all])) [clojure.test :refer :all]))
(defn koncat [k s] (defn koncat [k s]
@ -32,7 +32,7 @@
(testing "should suspend _only suspendable_ states that are currently started" (testing "should suspend _only suspendable_ states that are currently started"
(let [_ (mount/start) (let [_ (mount/start)
_ (mount/suspend)] _ (mount/suspend)]
(is (map? app-config)) (is (map? config))
(is (instance? clojure.tools.nrepl.server.Server nrepl)) (is (instance? clojure.tools.nrepl.server.Server nrepl))
(is (instance? datomic.peer.LocalConnection conn)) (is (instance? datomic.peer.LocalConnection conn))
(is (= web-server :w-suspended)) (is (= web-server :w-suspended))
@ -40,10 +40,10 @@
(testing "should resume _only suspendable_ states that are currently suspended" (testing "should resume _only suspendable_ states that are currently suspended"
(let [_ (mount/start) (let [_ (mount/start)
_ (mount/stop #'app/nrepl) _ (mount/stop #'app.example/nrepl)
_ (mount/suspend) _ (mount/suspend)
_ (mount/resume)] _ (mount/resume)]
(is (map? app-config)) (is (map? config))
(is (instance? mount.core.NotStartedState nrepl)) (is (instance? mount.core.NotStartedState nrepl))
(is (instance? datomic.peer.LocalConnection conn)) (is (instance? datomic.peer.LocalConnection conn))
(is (= web-server :w-resumed)) (is (= web-server :w-resumed))
@ -53,7 +53,7 @@
(let [_ (mount/start) (let [_ (mount/start)
_ (mount/suspend) _ (mount/suspend)
_ (mount/start)] _ (mount/start)]
(is (map? app-config)) (is (map? config))
(is (instance? clojure.tools.nrepl.server.Server nrepl)) (is (instance? clojure.tools.nrepl.server.Server nrepl))
(is (instance? datomic.peer.LocalConnection conn)) (is (instance? datomic.peer.LocalConnection conn))
(is (= web-server :w-resumed)) (is (= web-server :w-resumed))
@ -63,7 +63,7 @@
(let [_ (mount/start) (let [_ (mount/start)
_ (mount/suspend) _ (mount/suspend)
_ (mount/stop)] _ (mount/stop)]
(is (instance? mount.core.NotStartedState app-config)) (is (instance? mount.core.NotStartedState config))
(is (instance? mount.core.NotStartedState nrepl)) (is (instance? mount.core.NotStartedState nrepl))
(is (instance? mount.core.NotStartedState conn)) (is (instance? mount.core.NotStartedState conn))
(is (instance? mount.core.NotStartedState web-server))))) (is (instance? mount.core.NotStartedState web-server)))))
@ -74,7 +74,7 @@
(testing "when replacing a non suspendable state with a suspendable one, (testing "when replacing a non suspendable state with a suspendable one,
the later should be able to suspend/resume, the later should be able to suspend/resume,
the original should not be suspendable after resume and preserve its lifecycle fns after rollback/stop" the original should not be suspendable after resume and preserve its lifecycle fns after rollback/stop"
(let [_ (mount/start-with {#'app/nrepl #'check.suspend-resume-test/web-server}) (let [_ (mount/start-with {#'app.example/nrepl #'mount.suspend-resume-test/web-server})
_ (mount/suspend)] _ (mount/suspend)]
(is (= nrepl :w-suspended)) (is (= nrepl :w-suspended))
(is (instance? mount.core.NotStartedState web-server)) (is (instance? mount.core.NotStartedState web-server))
@ -91,7 +91,7 @@
(testing "when replacing a suspendable state with a non suspendable one, (testing "when replacing a suspendable state with a non suspendable one,
the later should not be suspendable, the later should not be suspendable,
the original should still be suspendable and preserve its lifecycle fns after the rollback/stop" the original should still be suspendable and preserve its lifecycle fns after the rollback/stop"
(let [_ (mount/start-with {#'check.suspend-resume-test/web-server #'check.suspend-resume-test/randomizer}) (let [_ (mount/start-with {#'mount.suspend-resume-test/web-server #'mount.suspend-resume-test/randomizer})
_ (mount/suspend)] _ (mount/suspend)]
(is (integer? web-server)) (is (integer? web-server))
(is (instance? mount.core.NotStartedState randomizer)) (is (instance? mount.core.NotStartedState randomizer))
@ -108,7 +108,7 @@
the original should still be suspended and preserve its lifecycle fns after the rollback/stop" the original should still be suspended and preserve its lifecycle fns after the rollback/stop"
(let [_ (mount/start) (let [_ (mount/start)
_ (mount/suspend) _ (mount/suspend)
_ (mount/start-with {#'check.suspend-resume-test/web-server #'app.nyse/conn}) ;; TODO: good to WARN on started states during "start-with" _ (mount/start-with {#'mount.suspend-resume-test/web-server #'app.nyse/conn}) ;; TODO: good to WARN on started states during "start-with"
_ (mount/suspend)] _ (mount/suspend)]
(is (instance? datomic.peer.LocalConnection conn)) (is (instance? datomic.peer.LocalConnection conn))
(is (= web-server :w-suspended)) ;; since the "conn" does not have a resume method, so web-server was not started (is (= web-server :w-suspended)) ;; since the "conn" does not have a resume method, so web-server was not started
@ -125,7 +125,8 @@
the original should still be suspended and preserve its lifecycle fns after the rollback/stop" the original should still be suspended and preserve its lifecycle fns after the rollback/stop"
(let [_ (mount/start) (let [_ (mount/start)
_ (mount/suspend) _ (mount/suspend)
_ (mount/start-with {#'check.suspend-resume-test/web-server #'check.suspend-resume-test/q-listener})] ;; TODO: good to WARN on started states during "start-with" _ (mount/start-with {#'mount.suspend-resume-test/web-server
#'mount.suspend-resume-test/q-listener})] ;; TODO: good to WARN on started states during "start-with"
(is (= q-listener :q-suspended)) (is (= q-listener :q-suspended))
(is (= web-server :q-resumed)) (is (= web-server :q-resumed))
(mount/suspend) (mount/suspend)

View file

@ -0,0 +1 @@
обещали подвезти