No such var: jdbc/with-transaction
After following this step of the guestbook guide, I get the following when running lein test.
$ lein test
2020-07-14 20:42:51,454 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
Syntax error compiling at (guestbook/test/db/core.clj:20:3).
No such var: jdbc/with-transaction
Full report at:
/tmp/clojure-16884464781834444921.edn
Tests failed.
Sample code in the guide has the namespace set like so:
(ns guestbook.test.db.core
(:require
[guestbook.db.core :refer [*db*] :as db]
[luminus-migrations.core :as migrations]
[clojure.test :refer :all]
[clojure.java.jdbc :as jdbc]
[guestbook.config :refer [env]]
[mount.core :as mount]))
when initially after creating the project with lein new luminus guestbook +h2 +immutant it was originally:
(ns guestbook.test.db.core
(:require
[guestbook.db.core :refer [*db*] :as db]
[java-time.pre-java8]
[luminus-migrations.core :as migrations]
[clojure.test :refer :all]
[next.jdbc :as jdbc]
[guestbook.config :refer [env]]
[mount.core :as mount]))
Found that swapping out [clojure.java.jdbc :as jdbc] for [next.jdbc :as jdbc] and leaving out [java-time.pre-java8] seemed to work.
Only issue after that is lein test seems to use guestbook_dev.db instead of guestbook_test.db, where entries to the db during the test are persisted and can be seen afterwards on the webpage when doing a lein run.
Also curious why the db files are not included in the .gitignore.
generated using Luminus version "3.78"
Not sure if this issue is better created here or in the luminus-framework/luminus repo.
Thanks for the heads up. The guide needs to be updated to use jdbc.next. I'll take a look at doing that. Not sure why lein test ends up using guestbook_dev.db for you. This should be controlled by the db specified in the config. When running lein test then test profile should be used:
:project/test {:jvm-opts ["-Dconf=test-config.edn"]
:resource-paths ["env/test/resources"]}
and test-config.edn should have:
{:port 3000
:database-url "jdbc:h2:./guestbook_test.db"}
I just tried a fresh project locally, and it appears to be working as expected for me.
And adding db files to .gitignore wouldn't hurt.