-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duct tests with integrant #60
Comments
Ideally in Duct you'll have three types of tests:
So my initial advice is to test the boundary functions directly: (deftest db-test
(jdbc/with-db-transaction [tx db-spec]
(jdbc/db-set-rollback-only! tx)
(seed-database tx)
(let [db (->Boundary tx)]
...))) If you want to test boundary functions in conjunction with your handler, perhaps because you're uncertain of the interactions between the handler and the database, then you could use (deftest db-test
(jdbc/with-db-transaction [tx db-spec]
(jdbc/db-set-rollback-only! tx)
(seed-database tx)
(let [db (->Boundary tx)
handler (init-key :foo.handler/bar {:db db})]
...))) Obviously you can wrap a lot of the above in a macro or function to automate the process of setting up the transaction and seeding the database. |
I would consider my tests falling into second case, that's why we will have code that's only pick the keys needed. As the example you provided, |
That makes sense. In which case, rather than using (deftest db-test
(jdbc/with-db-transaction [tx db-spec]
(jdbc/db-set-rollback-only! tx)
(let [config (assoc test-config :duct.database/sql {:connection tx})
system (-> config duct/prep (ig/init [:foo.handler/bar]))
handler (:foo.handler/bar system)]
...))) |
The Duct unit test example only cover init a handler with no dependences which is impossible in real world. Currently, if I want to do integration test with db. I need to do something like
is there any better method to test with
integrant
?The primary use case is for testing all the boundaries in duct, to see if they are healthy.
The text was updated successfully, but these errors were encountered: