Fork me on GitHub
#testing
<
2022-02-23
>
zeddan11:02:26

TL;DR: When setting up tests for a db backed web API, what things are required to write/set up yourself and what things do you get for free? I’m trying to wrap my head around an error when setting up tests for an existing application. At the moment we have no test suite, so the goal is to get integration tests working which includes calls to a db. I’m getting java.lang.IllegalArgumentException: No implementation of method: :-execute-all of protocol: #'next.jdbc.protocols/Executable found for class: nil which I assume means that there is no db set up in the tests? Being completely new to clojure I’m finding it hard to find resources on how to set up tests from the ground up so I’m kind of lost. When setting up tests in Ruby on Rails you get a test database and everything is already set up for you so I’m wondering how one would go on doing the equivalent thing in clojure. Do I have to do all the setup myself including setting up a test database and keeping the schema in sync and so on? If so, is there a common way to do it? Yesterday I was recommended checking Component for mocking carmine as a session store. Would it be appropriate to use Component for mocking the db aswell?

seancorfield17:02:53

"I’m getting java.lang.IllegalArgumentException: No implementation of method: :-execute-all of protocol: #'next.jdbc.protocols/Executable found for class: nil which I assume means that there is no db set up in the tests?" -- that means you're passing nil to next.jdbc/execute! instead of a valid database spec/connectable, which seems independent of any test context. Perhaps you can share some of the code you're trying to get running? Since you're completely new to Clojure, you may find you need to take a step back and get some basic stuff working first -- it sounds like you've perhaps just joined a team that already has a substantial codebase?

seancorfield17:02:15

(and, for what it's worth, we found Carmine to be more of a pain than just going directly against a solid Java library like Jedis via interop -- but that may not be a decision you have any control over @robin.saaf)