Last active
September 2, 2020 14:05
-
-
Save leorog/99a241ebc72eba95a7a1395f87232137 to your computer and use it in GitHub Desktop.
integrant with-system macro
This file contains hidden or 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
| (ns test-utils | |
| (:require [integrant.core :as ig])) | |
| (defmacro with-system [bindings & bodies] | |
| `(let [~(first bindings) (ig/init ~(second bindings)) | |
| ~@(drop 2 bindings)] | |
| (try | |
| (do | |
| ~@bodies) | |
| (finally | |
| (ig/halt! ~(first bindings)))))) | |
| (comment | |
| (with-system [sys {:some :config}] | |
| (testing "..." | |
| ) | |
| (testing "..." | |
| ) | |
| (testing "..." | |
| ) | |
| ) | |
| (with-system [sys {:some :config} | |
| {:keys [:db/conn :http/server]} sys] | |
| (testing "..." | |
| ) | |
| (testing "..." | |
| ) | |
| (testing "..." | |
| ) | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment