Fork me on GitHub
#ring-swagger
<
2018-01-24
>
mgrbyte15:01:17

Wondering how folks are testing apps that use compojure-api + datomic. Currently: have middleware that adds datomic and conn and db to the request; using datomock and clojure.core/with-redefs in tests to simulate using [1] as guide. Does this sound reasonable or is there a better way to do it? ([1]: http://vvvvalvalval.github.io/posts/2016-07-24-datomic-web-app-a-practical-guide.html#forking_database_connections). Thanks!

csm19:01:08

We wrote a testing library that spins up a datomic DB using mem storage, and then starts the service (via com.stuartsierra.component) with the temp DB passed into the system. We do this for each test with use-fixtures, initializing the schema and test data each run.

mgrbyte10:01:28

@U1WMPA45U Doing something similar with mount/start-with, but only the connection is passed in. Is the component system started for each request, or on "server start" (e.g ring init handler)

csm16:01:41

only on server start, and we do that in use-fixtures :each, so it’s a new DB and new server for each test

mgrbyte21:01:13

@U1WMPA45U ah. I want to obtain a new DB value on each request, so passing in on server start not an option :thinking_face: