Skip to content

Instantly share code, notes, and snippets.

@shirok
Created January 9, 2022 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirok/78437ba82886eb74ac11cf085d063049 to your computer and use it in GitHub Desktop.
Save shirok/78437ba82886eb74ac11cf085d063049 to your computer and use it in GitHub Desktop.
(defn- start-server []
(-> (duct/resource "my_project/config.edn")
(duct/read-config)
(duct/prep-config [:duct.profile/test])
(ig/init [:duct.router/ataraxy :duct.migrator/ragtime])))
(def #^:dynamic the-system
"During the test, this var holds the initialized system map."
nil)
(defn my-fixture [test-thunk]
"Run the test while binding the-system to the initialized system map."
(binding [the-system (start-server)]
(try
(test-thunk)
(finally
(ig/halt! the-system)))))
(defn call-handler [request]
"Call the toplevel router handler"
(let [handler (:duct.router/ataraxy the-system)]
(handler request)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment