update to lazytest 1.6.1

revert throws? back to thrown?

Signed-off-by: Sean Corfield <sean@corfield.org>
This commit is contained in:
Sean Corfield 2025-03-10 10:13:33 -07:00
parent 9d1c35b86c
commit 1642cc04ca
No known key found for this signature in database
4 changed files with 39 additions and 43 deletions

View file

@ -19,10 +19,7 @@
;; running tests/checks of various kinds: ;; running tests/checks of various kinds:
:test {:extra-paths ["test"] :test {:extra-paths ["test"]
:extra-deps {org.clojure/test.check {:mvn/version "1.1.1"} :extra-deps {org.clojure/test.check {:mvn/version "1.1.1"}
io.github.noahtheduke/lazytest io.github.noahtheduke/lazytest {:mvn/version "1.6.1"}
{:git/url "https://github.com/NoahTheDuke/lazytest/"
:git/sha "4e4a746bed3eb5642b67d63117aef60954fe424f"}
#_{:mvn/version "1.5.0"}
;; connection pooling ;; connection pooling
com.zaxxer/HikariCP {:mvn/version "6.2.1"} com.zaxxer/HikariCP {:mvn/version "6.2.1"}
com.mchange/c3p0 {:mvn/version "0.10.1"} com.mchange/c3p0 {:mvn/version "0.10.1"}

View file

@ -2,8 +2,7 @@
(ns next.jdbc.sql.builder-test (ns next.jdbc.sql.builder-test
"Tests for the SQL string building functions in next.jdbc.sql.builder." "Tests for the SQL string building functions in next.jdbc.sql.builder."
(:require [lazytest.core :refer [throws?]] (:require [lazytest.experimental.interfaces.clojure-test :refer [deftest is testing thrown?]]
[lazytest.experimental.interfaces.clojure-test :refer [deftest is testing]]
[next.jdbc.quoted :refer [mysql sql-server]] [next.jdbc.quoted :refer [mysql sql-server]]
[next.jdbc.sql.builder :as builder])) [next.jdbc.sql.builder :as builder]))
@ -159,11 +158,11 @@
(deftest test-for-update (deftest test-for-update
(testing "empty example (would be a SQL error)" (testing "empty example (would be a SQL error)"
(is (throws? IllegalArgumentException (is (thrown? IllegalArgumentException
#(builder/for-update :user (builder/for-update :user
{:status 42} {:status 42}
{} {}
{:table-fn sql-server :column-fn mysql})))) {:table-fn sql-server :column-fn mysql}))))
(testing "by example" (testing "by example"
(is (= (builder/for-update :user (is (= (builder/for-update :user
{:status 42} {:status 42}

View file

@ -2,8 +2,8 @@
(ns next.jdbc.sql-test (ns next.jdbc.sql-test
"Tests for the syntactic sugar SQL functions." "Tests for the syntactic sugar SQL functions."
(:require [lazytest.core :refer [around set-ns-context! throws?]] (:require [lazytest.core :refer [around set-ns-context!]]
[lazytest.experimental.interfaces.clojure-test :refer [deftest is testing]] [lazytest.experimental.interfaces.clojure-test :refer [deftest is testing thrown?]]
[next.jdbc :as jdbc] [next.jdbc :as jdbc]
[next.jdbc.specs :as specs] [next.jdbc.specs :as specs]
[next.jdbc.sql :as sql] [next.jdbc.sql :as sql]
@ -73,8 +73,8 @@
(when-not (xtdb?) ; XTDB does not support min/max on strings? (when-not (xtdb?) ; XTDB does not support min/max on strings?
(let [min-name (sql/aggregate-by-keys ds-opts :fruit "min(name)" :all)] (let [min-name (sql/aggregate-by-keys ds-opts :fruit "min(name)" :all)]
(is (= "Apple" min-name)))) (is (= "Apple" min-name))))
(is (throws? IllegalArgumentException (is (thrown? IllegalArgumentException
#(sql/aggregate-by-keys ds-opts :fruit "count(*)" :all {:columns []}))))) (sql/aggregate-by-keys ds-opts :fruit "count(*)" :all {:columns []})))))
(deftest test-get-by-id (deftest test-get-by-id
(let [ds-opts (jdbc/with-options (ds) (default-options))] (let [ds-opts (jdbc/with-options (ds) (default-options))]
@ -259,24 +259,24 @@
(is (= [] (sql/insert-multi! (ds) :fruit [] [])))))) (is (= [] (sql/insert-multi! (ds) :fruit [] []))))))
(deftest no-empty-example-maps (deftest no-empty-example-maps
(is (throws? clojure.lang.ExceptionInfo (is (thrown? clojure.lang.ExceptionInfo
#(sql/find-by-keys (ds) :fruit {}))) (sql/find-by-keys (ds) :fruit {})))
(is (throws? clojure.lang.ExceptionInfo (is (thrown? clojure.lang.ExceptionInfo
#(sql/update! (ds) :fruit {} {}))) (sql/update! (ds) :fruit {} {})))
(is (throws? clojure.lang.ExceptionInfo (is (thrown? clojure.lang.ExceptionInfo
#(sql/delete! (ds) :fruit {})))) (sql/delete! (ds) :fruit {}))))
(deftest no-empty-columns (deftest no-empty-columns
(is (throws? clojure.lang.ExceptionInfo (is (thrown? clojure.lang.ExceptionInfo
#(sql/insert-multi! (ds) :fruit [] [[] [] []])))) (sql/insert-multi! (ds) :fruit [] [[] [] []]))))
(deftest no-mismatched-columns (deftest no-mismatched-columns
(is (throws? IllegalArgumentException (is (thrown? IllegalArgumentException
#(sql/insert-multi! (ds) :fruit [{:name "Apple"} {:cost 1.23}])))) (sql/insert-multi! (ds) :fruit [{:name "Apple"} {:cost 1.23}]))))
(deftest no-empty-order-by (deftest no-empty-order-by
(is (throws? clojure.lang.ExceptionInfo (is (thrown? clojure.lang.ExceptionInfo
#(sql/find-by-keys (ds) :fruit (sql/find-by-keys (ds) :fruit
{:name "Apple"} {:name "Apple"}
{:order-by []})))) {:order-by []}))))

View file

@ -5,8 +5,8 @@
(:require (:require
[clojure.core.reducers :as r] [clojure.core.reducers :as r]
[clojure.string :as str] [clojure.string :as str]
[lazytest.core :refer [around throws?]] [lazytest.core :refer [around]]
[lazytest.experimental.interfaces.clojure-test :refer [deftest is testing]] [lazytest.experimental.interfaces.clojure-test :refer [deftest is testing thrown?]]
[next.jdbc :as jdbc] [next.jdbc :as jdbc]
[next.jdbc.connection :as c] [next.jdbc.connection :as c]
[next.jdbc.prepare :as prep] [next.jdbc.prepare :as prep]
@ -259,28 +259,28 @@ VALUES ('Pear', 'green', 49, 47)
(is (= 4 (count (jdbc/execute! con ["select * from fruit"])))) (is (= 4 (count (jdbc/execute! con ["select * from fruit"]))))
(is (= ac (.getAutoCommit con)))))) (is (= ac (.getAutoCommit con))))))
(testing "with-transaction exception" (testing "with-transaction exception"
(is (throws? Throwable (is (thrown? Throwable
#(jdbc/with-transaction [t (ds)] (jdbc/with-transaction [t (ds)]
(jdbc/execute! t [" (jdbc/execute! t ["
INSERT INTO fruit (name, appearance, cost, grade) INSERT INTO fruit (name, appearance, cost, grade)
VALUES ('Pear', 'green', 49, 47) VALUES ('Pear', 'green', 49, 47)
"]) "])
(is (jdbc/active-tx?) "should be in a transaction") (is (jdbc/active-tx?) "should be in a transaction")
(is (jdbc/active-tx? t) "connection should be in a transaction") (is (jdbc/active-tx? t) "connection should be in a transaction")
(throw (ex-info "abort" {}))))) (throw (ex-info "abort" {})))))
(is (= 4 (count (jdbc/execute! (ds) ["select * from fruit"])))) (is (= 4 (count (jdbc/execute! (ds) ["select * from fruit"]))))
(is (not (jdbc/active-tx?)) "should not be in a transaction") (is (not (jdbc/active-tx?)) "should not be in a transaction")
(with-open [con (jdbc/get-connection (ds))] (with-open [con (jdbc/get-connection (ds))]
(let [ac (.getAutoCommit con)] (let [ac (.getAutoCommit con)]
(is (throws? Throwable (is (thrown? Throwable
#(jdbc/with-transaction [t con] (jdbc/with-transaction [t con]
(jdbc/execute! t [" (jdbc/execute! t ["
INSERT INTO fruit (name, appearance, cost, grade) INSERT INTO fruit (name, appearance, cost, grade)
VALUES ('Pear', 'green', 49, 47) VALUES ('Pear', 'green', 49, 47)
"]) "])
(is (jdbc/active-tx?) "should be in a transaction") (is (jdbc/active-tx?) "should be in a transaction")
(is (jdbc/active-tx? t) "connection should be in a transaction") (is (jdbc/active-tx? t) "connection should be in a transaction")
(throw (ex-info "abort" {}))))) (throw (ex-info "abort" {})))))
(is (= 4 (count (jdbc/execute! con ["select * from fruit"])))) (is (= 4 (count (jdbc/execute! con ["select * from fruit"]))))
(is (= ac (.getAutoCommit con)))))) (is (= ac (.getAutoCommit con))))))
(testing "with-transaction call rollback" (testing "with-transaction call rollback"
@ -1106,8 +1106,8 @@ INSERT INTO fruit (name, appearance) VALUES (?,?)
(is (every? #(re-find #"(?i)^(#:fruit)?\{.*:_?id.*\}$" %) (is (every? #(re-find #"(?i)^(#:fruit)?\{.*:_?id.*\}$" %)
(into [] (map pr-str) (jdbc/plan (ds) ["select * from fruit"] (into [] (map pr-str) (jdbc/plan (ds) ["select * from fruit"]
(default-options))))) (default-options)))))
(is (throws? IllegalArgumentException (is (thrown? IllegalArgumentException
#(doall (take 3 (jdbc/plan (ds) ["select * from fruit"])))))) (doall (take 3 (jdbc/plan (ds) ["select * from fruit"]))))))
(deftest issue-204 (deftest issue-204
{:context [(around [f] (with-test-db f))]} {:context [(around [f] (with-test-db f))]}