Web Development with Clojure, Third Edition: Which jdbc (14)

I’ve stumbled on running the guestbook tests on pages 14–15, and realize there’s a mismatch between the book and the default generated code.

Having recently run lein new luminus guestbook, the require statement by default in test/clj/guestbook/db/core_test.clj has the require as

   [next.jdbc :as jdbc]

This failed when I tried to run tests because of

Syntax error compiling at (guestbook/db/core_test.clj:21:3).
No such var: jdbc/with-db-transaction

Spotting that the text currently (B16) has the require as

   [clojure.java.jdbc :as jdbc]

I changed it, but this leads to failures

ERROR in (messages-test) (core_deftype.clj:583)
Uncaught exception, not in assertion.
expected: nil
  actual: java.lang.IllegalArgumentException: No implementation of method: :get-level of protocol: #'clojure.java.jdbc/Connectable found for class: com.zaxxer.hikari.HikariDataSource

I haven’t fiddled with it any more than that, but it does suggest that the latest luminus may have made changes to next.jdbc, causing some mismatches with the text.

I should note that in the REPL I am able to call save-message! and get-messages just fine.

1 Like

The solution which uses next.jdbc is:

(deftest messages-test
  (jdbc/with-transaction [t-conn *db* {:rollback-only true}]
    (is (= 1 (db/save-message!
1 Like