Integration testing?


#1

Hello everyone,

I am currently working on an app that exposes datomic data through a rest api and I am interesting in what are the possible strategies for unit/integration testing.

As I understand these are my problems:

  • The in-memory store using (d/connect “datomic:mem://”) is not available anymore, at least in the cloud client
  • It is possible to start a local transactor that effectively uses an in-memory store, but how would I control its execution from within my tests ? I investigated the clojure.shell api but it seems limitated as it doesn’t seem I can send signals to spawned processes.
  • creating a ‘mock’ datomic component in my tests using with-redefs and with-redefs-fn would couple my tests to my schema, which is subject to changes.

I am interested in knowing if my assumptions above are correct and if yes, what are the strategies this community has adopted to solve that problem.

Regards


#2

I prefer integration tests be as real as possible. Why not use Solo node + a db naming convention and have clients talk to a real db?


#3

Hi Stu (and others who may know the answer),

The above question also mentioned unit testing. Is there an in-memory story around this for datomic cloud?

A great advantage of datomic on-prem was the ability to use it in unit tests without extra setup outside of the JVM running the tests.


#4

Hi Jon,

There is no in-memory store for Cloud at present. That said, there are several tricks to unit testing with Datomic, when I have time I will try to write up some of them.

Stu


#5

Thanks for the response, looking forward to anything you write about this topic.


#6

I am also interested in a in-memory store to run tests while not connected to the internet.


#7

Because this became a blocker for us, we ended up writing datomic-client-memdb to facilitate local development and CI testing with Cloud. It’s a small library that wraps Datomic Free in-memory databases with the Datomic Client protocols.

I wrote the library so let me know if you have any questions.