Version 0.9.58 of Cognitect dev-tools is now available for download.
See Cognitect dev-tools
2021/01/20 - 0.9.58
- Released dev-local 0.9.232.
2021/01/20 - dev-local 0.9.232
- Improvement: enable BigInt fressian handler
Version 0.9.58 of Cognitect dev-tools is now available for download.
See Cognitect dev-tools
Now Datomic DB dependent automated tests can be literally functional completely, using a memdb!
Normally you would do something like:
(let [conn (test-db-with-schema)]
(is (match? {,,,}
(do (system-under-test conn tx-params)
(d/qseq verification-query (d/db conn)))
where test-db-with-schema
is something like:
(defn test-db-with-schema
([] (test-db-with-schema your-apps-schema-if-there-is-only-one))
([schema]
(let [db-name (str (gensym "test-"))
db-ref {:db-name db-name}
client (d/client {:server-type :dev-local
:storage-dir :mem
:system "test"})
_ (d/create-database db-ref)
conn (d/connect client db-ref)]
(d/transact {:tx-data schema})
conn)))
(untested; just sketched in right in this forum’s textarea)
but I often separate my functions which compute just the tx-data, which then I can apply to a db - which already has he schema -, using a reducing function, something like
(defn with-tx [with-db tx-data]
(-> with-db (d/with {:tx-data tx-data}) :db-after))
then my tests are even more functional!
It can be used as (reduce with-tx (d/with-db conn) [tx1 tx2 ,,,])
, so we can construct the db state of a test scenario as a sequence of tx-data.