Fork me on GitHub

So I’m building up a spec to validate an input map, and one key of that map is a datomic database. For this reason I’ve written a spec that checks for the datomic.db.Db type. Because I want to be able to exercise etc. my spec, I’ve also written it with a generator:

(s/def :datomic/db
    #(instance? datomic.db.Db %)
    #(sgen/return (let [uri  "datomic:"
                        conn (partial d/connect uri)]
                    (d/create-database uri) 
                    (d/db (conn))))))


Is this a good way to go? And how would garbage collection work on the memory databases generated via exercise? Since the memory db doesn’t seem linked to a specific var but is created indirectly via a uri, is there a risk that I may fill up my memory with this?


Or would the fact that I’m reusing the same uri preventing multiple dbs from being created?


@achesnais datomic connections cache, so you’d only pay for one in that instance. i believe it won’t gc until you d/release it


Makes sense 🙂