luminus-framework / luminus-framework/examples

No such var: jdbc/with-transaction

Open
#12 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
65
Forks
29
PR merge metrics
No merged PRs in 30d

Description

After following [this step](https://luminusweb.com/docs/guestbook#adding_some_tests) 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"

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated guestbook/test/db/core.clj around line 20 and compare its namespace requires with the guide's example and the generated project. Run lein test and inspect whether it uses guestbook_dev.db or guestbook_test.db. Done means the guide and generated project agree, tests use the intended database, and the .gitignore question is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
database, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.