-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
189 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
{:linters {:refer-all {:exclude [clojure.test]} | ||
:unused-binding {:exclude-destructured-as true | ||
:exclude-destructured-keys-in-fn-args true}}} | ||
{:linters {:refer-all {:exclude [clojure.test]} | ||
:unused-binding {:exclude-unused-as true | ||
:exclude-destructured-as true | ||
:exclude-destructured-keys-in-fn-args true}} | ||
:skip-comments true} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
(ns princess-bride.db | ||
(:require [hugsql.core :as hugsql])) | ||
(ns princess-bride.db) | ||
|
||
(def db | ||
{:subprotocol "h2" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 12 additions & 11 deletions
23
hugsql-adapter-next-jdbc/test/hugsql_adapter_next_jdbc/core_test.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,41 @@ | ||
(ns hugsql-adapter-next-jdbc.core-test | ||
(:require [clojure.test :refer :all] | ||
[next.jdbc.result-set :as result-set] | ||
[hugsql.core :as hugsql] | ||
[hugsql.adapter.next-jdbc :as next-jdbc])) | ||
[hugsql.adapter.next-jdbc :as next-jdbc] | ||
[next.jdbc.result-set :as result-set] | ||
[hugsql-adapter-next-jdbc.core_test.sql :as sql])) | ||
|
||
|
||
(hugsql/def-db-fns "./hugsql_adapter_next_jdbc/queries.sql") | ||
(hugsql/set-adapter! (next-jdbc/hugsql-adapter-next-jdbc)) | ||
|
||
(def conn {:dbtype "h2:mem" :dbname "test"}) | ||
|
||
(deftest create-table-test | ||
(testing "Can create a table." | ||
(is (not (nil? (create-colors-table conn)))))) | ||
(is (not (nil? (sql/create-colors-table conn)))))) | ||
|
||
(deftest row-tests | ||
(testing "Can insert a row." | ||
(is (= (insert-color conn {:name "ocher" :r 204 :g 119 :b 34}) | ||
(is (= (sql/insert-color conn {:name "ocher" :r 204 :g 119 :b 34}) | ||
[{:next.jdbc/update-count 1}]))) | ||
(testing "Can insert another row." | ||
(is (= (insert-color conn {:name "crimson" :r 220 :g 20 :b 60}) | ||
(is (= (sql/insert-color conn {:name "crimson" :r 220 :g 20 :b 60}) | ||
[{:next.jdbc/update-count 1}]))) | ||
(testing ":insert command test" | ||
(is (= (insert-color-alt conn {:name "crimson" :r 220 :g 20 :b 60}) | ||
(is (= (sql/insert-color-alt conn {:name "crimson" :r 220 :g 20 :b 60}) | ||
[{:COLORS/ID 3}]))) | ||
(testing "Can insert and return affected rows" | ||
(is (= (update-color-affected conn {:r 100}) | ||
(is (= (sql/update-color-affected conn {:r 100}) | ||
3))) | ||
(testing "Can select a row." | ||
(is (= (:COLORS/ID (select-color-by-id conn {:id 1})) | ||
(is (= (:COLORS/ID (sql/select-color-by-id conn {:id 1})) | ||
1))) | ||
(testing "Can select multiple rows." | ||
(is (= (count (select-all-colors conn)) | ||
(is (= (count (sql/select-all-colors conn)) | ||
3)))) | ||
|
||
(deftest custom-builder-fn-test | ||
(hugsql/set-adapter! (next-jdbc/hugsql-adapter-next-jdbc {:builder-fn result-set/as-unqualified-maps})) | ||
(testing "Can select a row w/ custom builder fn" | ||
(is (= (:ID (select-color-by-id conn {:id 1})) | ||
(is (= (:ID (sql/select-color-by-id conn {:id 1})) | ||
1)))) |
4 changes: 4 additions & 0 deletions
4
hugsql-adapter-next-jdbc/test/hugsql_adapter_next_jdbc/core_test/sql.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(ns hugsql-adapter-next-jdbc.core-test.sql | ||
(:require [hugsql.core :as hugsql])) | ||
|
||
(hugsql/def-db-fns "hugsql_adapter_next_jdbc/queries.sql") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.