Skip to content

Instantly share code, notes, and snippets.

@leorog
Last active September 2, 2020 14:05
Show Gist options
  • Select an option

  • Save leorog/99a241ebc72eba95a7a1395f87232137 to your computer and use it in GitHub Desktop.

Select an option

Save leorog/99a241ebc72eba95a7a1395f87232137 to your computer and use it in GitHub Desktop.
integrant with-system macro
(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