Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such var: jdbc/with-transaction #12

Open
alexanderursu99 opened this issue Jul 15, 2020 · 2 comments
Open

No such var: jdbc/with-transaction #12

alexanderursu99 opened this issue Jul 15, 2020 · 2 comments

Comments

@alexanderursu99
Copy link

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"

@alexanderursu99
Copy link
Author

Not sure if this issue is better created here or in the luminus-framework/luminus repo.

@yogthos
Copy link
Member

yogthos commented Jul 15, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants