It's dirty and not thread-safe, but you can always replace any clojure function (caveat: that's not direct-linked (only clojure.core 1.8+)) temporarily during testing with with-redefs.
Instead of mocking out the functions, you might consider mocking out the database, or the data inside the database instead. There are projects to do so: https://github.com/yandex-qatools/postgresql-embedded . On Fri, Nov 18, 2016 at 12:17 PM Travis Daudelin <travis.daude...@gmail.com> wrote: > Hello everyone! > > I am investigating Clojure and, more specifically, Luminus > <http://www.luminusweb.net/>, for a new service my organization will be > building soon. My team and I are really excited by the prospect of trying > out something new. > > There is a lot that I like about Luminus' design, but I have some concerns > about its data-layer is implemented. To be clear, what I mean by "data > layer" is the code that deals with querying a SQL database. As I understand > it, Luminus uses HugSQL <http://www.hugsql.org/> and Mount > <https://github.com/tolitius/mount> to dynamically construct a set of > functions at run time and injects them into a namespace that the rest of > the application code can then call to perform DB operations. This is very > interesting, but I worry that this tightly couples my application code with > the data code. For example, what if I want to mock these functions in my > unit tests so that my tests don't need to depend on a database connection, > or so that I can mock various DB error scenarios to test that my > application code handles them appropriately? > > Coming from a Java background, I would normally place data layer code > behind an interface and then at run time pass an implementation of that > interface to my application code. This allows me a lot of freedom during > unit testing. What would an equivalent design pattern be in Luminus? > > Thanks in advance for any insights! > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.