There are a number of options here depending on your workflow. You could override the dynamic var, create a separate connection for tests and pass it around explicitly in test code, or get the connection from the environment. The last option is what I tend to do, the profiles.clj will contain separate URLs for testing and dev databases:
{:profiles/dev {:env {:database-url "jdbc:postgresql://localhost/myapp_dev?user=db_user_name_here&password=db_user_password_here"}} :profiles/test {:env {:database-url "jdbc:postgresql://localhost/myapp_test?user=db_user_name_here&password=db_user_password_here"}}} The tests run in the test profile and so get the test database connection from the environment. On Wednesday, August 5, 2015 at 2:34:31 PM UTC-4, James Reeves wrote: > > On 5 August 2015 at 18:04, Dmitri <dmitri....@gmail.com <javascript:>> > wrote: > >> I agree that wrapping the functions is a sensible approach. Using >> wrap-transaction is precisely how I ended up doing it with the conman yesql >> wrapper https://github.com/luminus-framework/conman >> >> The approach I took there is to have the generated functions use the >> connection atom, and have with-transaction rebind it to the transactional >> connection within its scope. However, the functions also accept an explicit >> connection, and with-transaction also provides explicit access to the >> transactional connection >> > > So when you're testing, presumably you use a dynamic binding to override > the global connection to the test database? > > - James > -- 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.