I'm probably missing something simple, but I'm not experienced enough with clojure to understand the error I'm getting.
I have a simple luminus clojure app setup with the Monger library to handle my MongoDB connection. I've added a simple test that should always pass to my tests file.
(testing "create user"
(let [result (db/create-user "test" "test" "test")]
(is (true? true))))
This doesn't work however, and throws the following error
java.lang.ClassCastException: mount.core.DerefableState cannot be cast to com.mongodb.DB
I'm assuming this has to do with the test environment not properly setting up the database stuff and failing there. I've done a bit of searching, but nothing helpful has come up and there doesn't appear to be any testing help in the Monger Docs. I know for sure that the above create-user
call does work when running in the actual environment.
It seems like you're not binding your database before the tests run:
https://github.com/yogthos/clojure-error-message-catalog/blob/master/lib/mount/derefablestate-cannot-be-cast-to-ifn.md
I haven't used Luminus but I do have some integration tests for database related code in which I initialize my monger database connection ahead of time: