Last active
October 6, 2016 18:11
-
-
Save rbxbx/0107da08cd072e25c2118498de7c1ce0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro with-system | |
"start a system, execute the body, and stop the system when done." | |
[[bound sys] & body] | |
`(let [system# (component/start ~sys) | |
~bound system#] | |
(try | |
~@body | |
(finally | |
(component/stop system#))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro with-test-server [[bound {:keys [quiet?] :or {quiet? true}}] & body] | |
`(binding [*out* (if ~quiet? (StringWriter.) | |
*out*)] | |
(let [system# (component/start (build-system)) | |
~bound (get-in system# [:webserver :connection]) | |
db# (get-in system# [:database :connection]) | |
db-password# (get-in system# [:config :database-password]) | |
aws-opts# (get system# :aws-client-opts)] | |
(try | |
(do | |
(db/drop-tables db#) | |
(db/migrate db# db-password#)) | |
~@body | |
(finally | |
(do (db/drop-tables db#) | |
(drop-dynamo-tables aws-opts#) | |
(component/stop system#))))))) | |
(defmacro with-test-server-system [[bound {:keys [quiet?] :or {quiet? true}}] [sys-bound] & body] | |
`(binding [*out* (if ~quiet? (StringWriter.) | |
*out*)] | |
(let [system# (component/start (build-system)) | |
~bound (get-in system# [:webserver :connection]) | |
db# (get-in system# [:database :connection]) | |
db-password# (get-in system# [:config :database-password]) | |
aws-opts# (get system# :aws-client-opts) | |
~sys-bound system#] | |
(try | |
(do | |
(db/drop-tables db#) | |
(db/migrate db# db-password#)) | |
~@body | |
(finally | |
(do (db/drop-tables db#) | |
(drop-dynamo-tables aws-opts#) | |
(component/stop system#))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment