From 8e34001122b11d99d628df947d7cd9b3af8b80a0 Mon Sep 17 00:00:00 2001 From: anatoly Date: Mon, 7 Dec 2015 19:50:03 -0500 Subject: [PATCH] reorging sample clj/cljs apps. ready for cljs tests --- test/app/config.clj => dev/clj/app/conf.clj | 6 ++--- test/app/app.clj => dev/clj/app/example.clj | 6 ++--- {test => dev/clj}/app/nyse.clj | 6 ++--- {test => dev/clj}/app/utils/datomic.clj | 0 {test => dev/clj}/app/utils/logging.clj | 0 .../example => dev/cljs/app}/audit_log.cljs | 2 +- .../app_config.cljs => dev/cljs/app/conf.cljs | 6 ++--- .../app.cljs => dev/cljs/app/example.cljs | 10 ++++---- .../example => dev/cljs/app}/websockets.cljs | 6 ++--- dev/dev.clj | 9 +++---- {test => dev}/resources/config.edn | 0 .../resources}/public/index.html | 0 project.clj | 12 ++++----- test/check/cleanup_dirty_states_test.clj | 13 ---------- test/clj/mount/cleanup_dirty_states_test.clj | 13 ++++++++++ .../mount}/deref/fun_with_values_test.clj | 24 +++++++++--------- .../mount}/deref/private_fun_test.clj | 6 ++--- .../mount}/fun_with_values_test.clj | 22 ++++++++-------- test/{check => clj/mount}/parts_test.clj | 4 +-- .../{check => clj/mount}/private_fun_test.clj | 6 ++--- test/{check => clj/mount}/start_with_test.clj | 22 ++++++++-------- .../mount}/start_without_test.clj | 10 ++++---- .../{check => clj/mount}/stop_except_test.clj | 16 ++++++------ .../mount}/suspend_resume_test.clj | 25 ++++++++++--------- test/cljs/mount/waiting.for.cljs.tests | 1 + 25 files changed, 112 insertions(+), 113 deletions(-) rename test/app/config.clj => dev/clj/app/conf.clj (73%) rename test/app/app.clj => dev/clj/app/example.clj (95%) rename {test => dev/clj}/app/nyse.clj (80%) rename {test => dev/clj}/app/utils/datomic.clj (100%) rename {test => dev/clj}/app/utils/logging.clj (100%) rename {test/mount/example => dev/cljs/app}/audit_log.cljs (96%) rename test/mount/example/app_config.cljs => dev/cljs/app/conf.cljs (53%) rename test/mount/example/app.cljs => dev/cljs/app/example.cljs (74%) rename {test/mount/example => dev/cljs/app}/websockets.cljs (82%) rename {test => dev}/resources/config.edn (100%) rename {dev-resources => dev/resources}/public/index.html (100%) delete mode 100644 test/check/cleanup_dirty_states_test.clj create mode 100644 test/clj/mount/cleanup_dirty_states_test.clj rename test/{check => clj/mount}/deref/fun_with_values_test.clj (58%) rename test/{check => clj/mount}/deref/private_fun_test.clj (64%) rename test/{check => clj/mount}/fun_with_values_test.clj (62%) rename test/{check => clj/mount}/parts_test.clj (84%) rename test/{check => clj/mount}/private_fun_test.clj (63%) rename test/{check => clj/mount}/start_with_test.clj (69%) rename test/{check => clj/mount}/start_without_test.clj (62%) rename test/{check => clj/mount}/stop_except_test.clj (68%) rename test/{check => clj/mount}/suspend_resume_test.clj (87%) create mode 100644 test/cljs/mount/waiting.for.cljs.tests diff --git a/test/app/config.clj b/dev/clj/app/conf.clj similarity index 73% rename from test/app/config.clj rename to dev/clj/app/conf.clj index 1e18a59..3273a95 100644 --- a/test/app/config.clj +++ b/dev/clj/app/conf.clj @@ -1,4 +1,4 @@ -(ns app.config +(ns app.conf (:require [mount.core :as mount :refer [defstate]] [clojure.edn :as edn] [clojure.tools.logging :refer [info]])) @@ -9,5 +9,5 @@ slurp edn/read-string)) -(defstate app-config - :start (load-config "test/resources/config.edn")) +(defstate config + :start (load-config "dev/resources/config.edn")) diff --git a/test/app/app.clj b/dev/clj/app/example.clj similarity index 95% rename from test/app/app.clj rename to dev/clj/app/example.clj index f529c95..81ffb49 100644 --- a/test/app/app.clj +++ b/dev/clj/app/example.clj @@ -1,9 +1,9 @@ -(ns app +(ns app.example (:require [datomic.api :as d] [clojure.tools.nrepl.server :refer [start-server stop-server]] [mount.core :as mount :refer [defstate]] [app.utils.datomic :refer [touch]] - [app.config :refer [app-config]] + [app.conf :refer [config]] [app.nyse :as nyse])) ;; example on creating a network REPL @@ -11,7 +11,7 @@ (start-server :bind host :port port)) ;; 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)) ;; datomic schema diff --git a/test/app/nyse.clj b/dev/clj/app/nyse.clj similarity index 80% rename from test/app/nyse.clj rename to dev/clj/app/nyse.clj index 649dfad..f6a8ede 100644 --- a/test/app/nyse.clj +++ b/dev/clj/app/nyse.clj @@ -2,7 +2,7 @@ (:require [mount.core :as mount :refer [defstate]] [datomic.api :as d] [clojure.tools.logging :refer [info]] - [app.config :refer [app-config]])) + [app.conf :refer [config]])) (defn- new-connection [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) (d/delete-database uri))) -(defstate conn :start (new-connection app-config) - :stop (disconnect app-config conn)) +(defstate conn :start (new-connection config) + :stop (disconnect config conn)) diff --git a/test/app/utils/datomic.clj b/dev/clj/app/utils/datomic.clj similarity index 100% rename from test/app/utils/datomic.clj rename to dev/clj/app/utils/datomic.clj diff --git a/test/app/utils/logging.clj b/dev/clj/app/utils/logging.clj similarity index 100% rename from test/app/utils/logging.clj rename to dev/clj/app/utils/logging.clj diff --git a/test/mount/example/audit_log.cljs b/dev/cljs/app/audit_log.cljs similarity index 96% rename from test/mount/example/audit_log.cljs rename to dev/cljs/app/audit_log.cljs index f4525ec..9ce586c 100644 --- a/test/mount/example/audit_log.cljs +++ b/dev/cljs/app/audit_log.cljs @@ -1,4 +1,4 @@ -(ns mount.example.audit-log +(ns app.audit-log (:require [datascript.core :as d] [cljs-time.core :refer [now]]) (:require-macros [mount.core :refer [defstate]])) diff --git a/test/mount/example/app_config.cljs b/dev/cljs/app/conf.cljs similarity index 53% rename from test/mount/example/app_config.cljs rename to dev/cljs/app/conf.cljs index c3687fc..14d0adb 100644 --- a/test/mount/example/app_config.cljs +++ b/dev/cljs/app/conf.cljs @@ -1,9 +1,9 @@ -(ns mount.example.app-config - (:require [mount.example.audit-log :refer [audit log]]) +(ns app.conf + (:require [app.audit-log :refer [audit log]]) (:require-macros [mount.core :refer [defstate]])) (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/"}}) (defstate config :start (load-config "resources/config.end")) diff --git a/test/mount/example/app.cljs b/dev/cljs/app/example.cljs similarity index 74% rename from test/mount/example/app.cljs rename to dev/cljs/app/example.cljs index 20f18c2..2b9b475 100644 --- a/test/mount/example/app.cljs +++ b/dev/cljs/app/example.cljs @@ -1,8 +1,8 @@ -(ns mount.example.app +(ns app.example (:require [mount.core :as mount] - [mount.example.app-config] - [mount.example.websockets] - [mount.example.audit-log :refer [log find-all-logs]] + [app.conf] + [app.websockets] + [app.audit-log :refer [log find-all-logs]] [cljs-time.format :refer [unparse formatters]] [hiccups.runtime :as hiccupsrt]) (:require-macros [hiccups.core :as hiccups :refer [html]])) @@ -19,7 +19,7 @@ (mount/start) ;; 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 (js/setTimeout #(show-log) 1000) diff --git a/test/mount/example/websockets.cljs b/dev/cljs/app/websockets.cljs similarity index 82% rename from test/mount/example/websockets.cljs rename to dev/cljs/app/websockets.cljs index 49cd25a..ae0dc4c 100644 --- a/test/mount/example/websockets.cljs +++ b/dev/cljs/app/websockets.cljs @@ -1,6 +1,6 @@ -(ns mount.example.websockets - (:require [mount.example.app-config :refer [config]] - [mount.example.audit-log :refer [audit log]]) +(ns app.websockets + (:require [app.conf :refer [config]] + [app.audit-log :refer [audit log]]) (:require-macros [mount.core :refer [defstate]])) (defn ws-status [ws] diff --git a/dev/dev.clj b/dev/dev.clj index e74d05b..1982e87 100644 --- a/dev/dev.clj +++ b/dev/dev.clj @@ -10,18 +10,15 @@ [clojure.string :as str] [clojure.test :as test] [clojure.tools.namespace.repl :as tn] - [check.parts-test] - [check.start-with-test] - [check.suspend-resume-test] [mount.core :as mount] [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 [] (with-logging-status) - (mount/start #'app.config/app-config + (mount/start #'app.conf/config #'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 [] (mount/stop)) diff --git a/test/resources/config.edn b/dev/resources/config.edn similarity index 100% rename from test/resources/config.edn rename to dev/resources/config.edn diff --git a/dev-resources/public/index.html b/dev/resources/public/index.html similarity index 100% rename from dev-resources/public/index.html rename to dev/resources/public/index.html diff --git a/project.clj b/project.clj index 36f25f2..898a5ba 100644 --- a/project.clj +++ b/project.clj @@ -9,7 +9,7 @@ :dependencies [[org.clojure/clojure "1.7.0"] [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"] [hiccups "0.3.0"] [com.andrewmcveigh/cljs-time "0.3.14"] @@ -28,18 +28,18 @@ [:cljsbuild :builds :prod :compiler :output-to]] :cljsbuild { :builds {:dev - {:source-paths ["src" "test"] + {:source-paths ["dev/cljs" "test/cljs"] :figwheel true - :compiler {:main mount.example.app + :compiler {:main app.example :asset-path "js/compiled/out" - :output-to "dev-resources/public/js/compiled/mount.js" - :output-dir "dev-resources/public/js/compiled/out" + :output-to "dev/resources/public/js/compiled/mount.js" + :output-dir "dev/resources/public/js/compiled/out" :optimizations :none :source-map true :source-map-timestamp true}} :prod {: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 :pretty-print false}}}}}}) diff --git a/test/check/cleanup_dirty_states_test.clj b/test/check/cleanup_dirty_states_test.clj deleted file mode 100644 index 73fd0a8..0000000 --- a/test/check/cleanup_dirty_states_test.clj +++ /dev/null @@ -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)))) diff --git a/test/clj/mount/cleanup_dirty_states_test.clj b/test/clj/mount/cleanup_dirty_states_test.clj new file mode 100644 index 0000000..2d62575 --- /dev/null +++ b/test/clj/mount/cleanup_dirty_states_test.clj @@ -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)))) diff --git a/test/check/deref/fun_with_values_test.clj b/test/clj/mount/deref/fun_with_values_test.clj similarity index 58% rename from test/check/deref/fun_with_values_test.clj rename to test/clj/mount/deref/fun_with_values_test.clj index a71b336..eeb3883 100644 --- a/test/check/deref/fun_with_values_test.clj +++ b/test/clj/mount/deref/fun_with_values_test.clj @@ -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]] [clojure.test :refer :all])) @@ -28,17 +28,17 @@ (defn with-fun-and-values [f] (mount/in-cljc-mode) - (require :reload 'check.deref.fun-with-values-test) - (mount/start #'check.deref.fun-with-values-test/scalar - #'check.deref.fun-with-values-test/fun - #'check.deref.fun-with-values-test/with-fun - #'check.deref.fun-with-values-test/with-partial - #'check.deref.fun-with-values-test/f-in-f - #'check.deref.fun-with-values-test/f-args - #'check.deref.fun-with-values-test/f-no-args-value - #'check.deref.fun-with-values-test/f-no-args - #'check.deref.fun-with-values-test/private-f - #'check.deref.fun-with-values-test/f-value) + (require :reload 'mount.deref.fun-with-values-test) + (mount/start #'mount.deref.fun-with-values-test/scalar + #'mount.deref.fun-with-values-test/fun + #'mount.deref.fun-with-values-test/with-fun + #'mount.deref.fun-with-values-test/with-partial + #'mount.deref.fun-with-values-test/f-in-f + #'mount.deref.fun-with-values-test/f-args + #'mount.deref.fun-with-values-test/f-no-args-value + #'mount.deref.fun-with-values-test/f-no-args + #'mount.deref.fun-with-values-test/private-f + #'mount.deref.fun-with-values-test/f-value) (f) (mount/stop) (mount/in-clj-mode)) diff --git a/test/check/deref/private_fun_test.clj b/test/clj/mount/deref/private_fun_test.clj similarity index 64% rename from test/check/deref/private_fun_test.clj rename to test/clj/mount/deref/private_fun_test.clj index 4996ff9..38f1dbe 100644 --- a/test/check/deref/private_fun_test.clj +++ b/test/clj/mount/deref/private_fun_test.clj @@ -1,11 +1,11 @@ -(ns check.deref.private-fun-test +(ns mount.deref.private-fun-test (: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])) (defn with-fun-and-values [f] (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) (mount/stop) (mount/in-clj-mode)) diff --git a/test/check/fun_with_values_test.clj b/test/clj/mount/fun_with_values_test.clj similarity index 62% rename from test/check/fun_with_values_test.clj rename to test/clj/mount/fun_with_values_test.clj index f1f4772..22693ad 100644 --- a/test/check/fun_with_values_test.clj +++ b/test/clj/mount/fun_with_values_test.clj @@ -1,4 +1,4 @@ -(ns check.fun-with-values-test +(ns mount.fun-with-values-test (:require [mount.core :as mount :refer [defstate]] [clojure.test :refer :all])) @@ -27,16 +27,16 @@ (defstate private-f :start pf) (defn with-fun-and-values [f] - (mount/start #'check.fun-with-values-test/scalar - #'check.fun-with-values-test/fun - #'check.fun-with-values-test/with-fun - #'check.fun-with-values-test/with-partial - #'check.fun-with-values-test/f-in-f - #'check.fun-with-values-test/f-args - #'check.fun-with-values-test/f-no-args-value - #'check.fun-with-values-test/f-no-args - #'check.fun-with-values-test/private-f - #'check.fun-with-values-test/f-value) + (mount/start #'mount.fun-with-values-test/scalar + #'mount.fun-with-values-test/fun + #'mount.fun-with-values-test/with-fun + #'mount.fun-with-values-test/with-partial + #'mount.fun-with-values-test/f-in-f + #'mount.fun-with-values-test/f-args + #'mount.fun-with-values-test/f-no-args-value + #'mount.fun-with-values-test/f-no-args + #'mount.fun-with-values-test/private-f + #'mount.fun-with-values-test/f-value) (f) (mount/stop)) diff --git a/test/check/parts_test.clj b/test/clj/mount/parts_test.clj similarity index 84% rename from test/check/parts_test.clj rename to test/clj/mount/parts_test.clj index 53f4b38..c387ce3 100644 --- a/test/check/parts_test.clj +++ b/test/clj/mount/parts_test.clj @@ -1,4 +1,4 @@ -(ns check.parts-test +(ns mount.parts-test (:require [mount.core :as mount :refer [defstate] :as m] [app.nyse :refer [conn]] [clojure.test :refer :all])) @@ -6,7 +6,7 @@ (defstate should-not-start :start #(constantly 42)) (defn with-parts [f] - (m/start #'app.config/app-config #'app.nyse/conn) + (m/start #'app.conf/config #'app.nyse/conn) (f) (m/stop)) diff --git a/test/check/private_fun_test.clj b/test/clj/mount/private_fun_test.clj similarity index 63% rename from test/check/private_fun_test.clj rename to test/clj/mount/private_fun_test.clj index 2f2c413..85cc31c 100644 --- a/test/check/private_fun_test.clj +++ b/test/clj/mount/private_fun_test.clj @@ -1,10 +1,10 @@ -(ns check.private-fun-test +(ns mount.private-fun-test (: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])) (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) (mount/stop)) diff --git a/test/check/start_with_test.clj b/test/clj/mount/start_with_test.clj similarity index 69% rename from test/check/start_with_test.clj rename to test/clj/mount/start_with_test.clj index 8e362c0..59b0b98 100644 --- a/test/check/start_with_test.clj +++ b/test/clj/mount/start_with_test.clj @@ -1,8 +1,8 @@ -(ns check.start-with-test +(ns mount.start-with-test (:require [mount.core :as mount :refer [defstate]] - [app.config :refer [app-config]] + [app.conf :refer [config]] [app.nyse :refer [conn]] - [app :refer [nrepl]] + [app.example :refer [nrepl]] [clojure.test :refer :all])) (defstate test-conn :start 42 @@ -13,22 +13,22 @@ (deftest start-with (testing "should start with substitutes" - (let [_ (mount/start-with {#'app.nyse/conn #'check.start-with-test/test-conn - #'app/nrepl #'check.start-with-test/test-nrepl})] - (is (map? app-config)) + (let [_ (mount/start-with {#'app.nyse/conn #'mount.start-with-test/test-conn + #'app.example/nrepl #'mount.start-with-test/test-nrepl})] + (is (map? config)) (is (vector? nrepl)) (is (= conn 42)) (mount/stop))) (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 (= conn 42)) (mount/stop))) (testing "should start normally after start-with" (let [_ (mount/start)] - (is (map? app-config)) + (is (map? config)) (is (instance? clojure.tools.nrepl.server.Server nrepl)) (is (instance? datomic.peer.LocalConnection conn)) (is (= test-conn 42)) @@ -36,9 +36,9 @@ (mount/stop))) (testing "should start-without normally after start-with" - (let [_ (mount/start-without #'check.start-with-test/test-conn - #'check.start-with-test/test-nrepl)] - (is (map? app-config)) + (let [_ (mount/start-without #'mount.start-with-test/test-conn + #'mount.start-with-test/test-nrepl)] + (is (map? config)) (is (instance? clojure.tools.nrepl.server.Server nrepl)) (is (instance? datomic.peer.LocalConnection conn)) (is (instance? mount.core.NotStartedState test-conn)) diff --git a/test/check/start_without_test.clj b/test/clj/mount/start_without_test.clj similarity index 62% rename from test/check/start_without_test.clj rename to test/clj/mount/start_without_test.clj index 1459dae..5d9ac77 100644 --- a/test/check/start_without_test.clj +++ b/test/clj/mount/start_without_test.clj @@ -1,18 +1,18 @@ -(ns check.start-without-test +(ns mount.start-without-test (:require [mount.core :as m] - [app.config :refer [app-config]] + [app.conf :refer [config]] [app.nyse :refer [conn]] - [app :refer [nrepl]] + [app.example :refer [nrepl]] [clojure.test :refer :all])) (defn without [f] - (m/start-without #'app.nyse/conn #'app/nrepl) + (m/start-without #'app.nyse/conn #'app.example/nrepl) (f) (m/stop)) (use-fixtures :each without) (deftest start-without-states - (is (map? app-config)) + (is (map? config)) (is (instance? mount.core.NotStartedState nrepl)) (is (instance? mount.core.NotStartedState conn))) diff --git a/test/check/stop_except_test.clj b/test/clj/mount/stop_except_test.clj similarity index 68% rename from test/check/stop_except_test.clj rename to test/clj/mount/stop_except_test.clj index b314c31..bc2c452 100644 --- a/test/check/stop_except_test.clj +++ b/test/clj/mount/stop_except_test.clj @@ -1,31 +1,31 @@ -(ns check.stop-except-test +(ns mount.stop-except-test (:require [mount.core :as mount :refer [defstate]] - [app.config :refer [app-config]] + [app.conf :refer [config]] [app.nyse :refer [conn]] - [app :refer [nrepl]] + [app.example :refer [nrepl]] [clojure.test :refer :all])) (deftest stop-except (testing "should stop all except nrepl" (let [_ (mount/start) - _ (mount/stop-except #'app.nyse/conn #'app.config/app-config)] - (is (map? app-config)) + _ (mount/stop-except #'app.nyse/conn #'app.conf/config)] + (is (map? config)) (is (instance? datomic.peer.LocalConnection conn)) (is (instance? mount.core.NotStartedState nrepl)) (mount/stop))) (testing "should start normally after stop-except" (let [_ (mount/start)] - (is (map? app-config)) + (is (map? config)) (is (instance? clojure.tools.nrepl.server.Server nrepl)) (is (instance? datomic.peer.LocalConnection conn)) (mount/stop))) (testing "should stop all normally after stop-except" (let [_ (mount/start) - _ (mount/stop-except #'app.nyse/conn #'app.config/app-config) + _ (mount/stop-except #'app.nyse/conn #'app.conf/config) _ (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 nrepl))))) diff --git a/test/check/suspend_resume_test.clj b/test/clj/mount/suspend_resume_test.clj similarity index 87% rename from test/check/suspend_resume_test.clj rename to test/clj/mount/suspend_resume_test.clj index eb37ace..d96d389 100644 --- a/test/check/suspend_resume_test.clj +++ b/test/clj/mount/suspend_resume_test.clj @@ -1,8 +1,8 @@ -(ns check.suspend-resume-test +(ns mount.suspend-resume-test (:require [mount.core :as mount :refer [defstate]] - [app.config :refer [app-config]] + [app.conf :refer [config]] [app.nyse :refer [conn]] - [app :refer [nrepl]] + [app.example :refer [nrepl]] [clojure.test :refer :all])) (defn koncat [k s] @@ -32,7 +32,7 @@ (testing "should suspend _only suspendable_ states that are currently started" (let [_ (mount/start) _ (mount/suspend)] - (is (map? app-config)) + (is (map? config)) (is (instance? clojure.tools.nrepl.server.Server nrepl)) (is (instance? datomic.peer.LocalConnection conn)) (is (= web-server :w-suspended)) @@ -40,10 +40,10 @@ (testing "should resume _only suspendable_ states that are currently suspended" (let [_ (mount/start) - _ (mount/stop #'app/nrepl) + _ (mount/stop #'app.example/nrepl) _ (mount/suspend) _ (mount/resume)] - (is (map? app-config)) + (is (map? config)) (is (instance? mount.core.NotStartedState nrepl)) (is (instance? datomic.peer.LocalConnection conn)) (is (= web-server :w-resumed)) @@ -53,7 +53,7 @@ (let [_ (mount/start) _ (mount/suspend) _ (mount/start)] - (is (map? app-config)) + (is (map? config)) (is (instance? clojure.tools.nrepl.server.Server nrepl)) (is (instance? datomic.peer.LocalConnection conn)) (is (= web-server :w-resumed)) @@ -63,7 +63,7 @@ (let [_ (mount/start) _ (mount/suspend) _ (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 conn)) (is (instance? mount.core.NotStartedState web-server))))) @@ -74,7 +74,7 @@ (testing "when replacing a non suspendable state with a suspendable one, the later should be able to suspend/resume, 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)] (is (= nrepl :w-suspended)) (is (instance? mount.core.NotStartedState web-server)) @@ -91,7 +91,7 @@ (testing "when replacing a suspendable state with a non suspendable one, the later should not be suspendable, 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)] (is (integer? web-server)) (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" (let [_ (mount/start) _ (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)] (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 @@ -125,7 +125,8 @@ the original should still be suspended and preserve its lifecycle fns after the rollback/stop" (let [_ (mount/start) _ (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 (= web-server :q-resumed)) (mount/suspend) diff --git a/test/cljs/mount/waiting.for.cljs.tests b/test/cljs/mount/waiting.for.cljs.tests new file mode 100644 index 0000000..a511b1f --- /dev/null +++ b/test/cljs/mount/waiting.for.cljs.tests @@ -0,0 +1 @@ +обещали подвезти