Add test for as-maps-adapter
This commit is contained in:
parent
fed305dd2b
commit
57f146ee41
1 changed files with 21 additions and 0 deletions
|
|
@ -109,6 +109,27 @@
|
||||||
(is (contains? row (if (postgres?) :fruit/appearance :FRUIT/appearance)))
|
(is (contains? row (if (postgres?) :fruit/appearance :FRUIT/appearance)))
|
||||||
(is (nil? ((if (postgres?) :fruit/appearance :FRUIT/appearance) row)))
|
(is (nil? ((if (postgres?) :fruit/appearance :FRUIT/appearance) row)))
|
||||||
(is (= 3 ((if (postgres?) :fruit/id :FRUIT/id) row)))
|
(is (= 3 ((if (postgres?) :fruit/id :FRUIT/id) row)))
|
||||||
|
(is (= "Peach" ((if (postgres?) :fruit/name :FRUIT/name) row)))))
|
||||||
|
(testing "adapted row builder"
|
||||||
|
(let [row (p/-execute-one (ds)
|
||||||
|
["select * from fruit where id = ?" 3]
|
||||||
|
{:builder-fn (rs/as-maps-adapter
|
||||||
|
rs/as-modified-maps
|
||||||
|
(fn [^ResultSet rs
|
||||||
|
^ResultSetMetaData rsmeta
|
||||||
|
^Integer i]
|
||||||
|
(condp = (.getColumnType rsmeta i)
|
||||||
|
java.sql.Types/VARCHAR
|
||||||
|
(.getString rs i)
|
||||||
|
java.sql.Types/INTEGER
|
||||||
|
(.getLong rs i)
|
||||||
|
(.getObject rs i))))
|
||||||
|
:label-fn str/lower-case
|
||||||
|
:qualifier-fn identity})]
|
||||||
|
(is (map? row))
|
||||||
|
(is (contains? row (if (postgres?) :fruit/appearance :FRUIT/appearance)))
|
||||||
|
(is (nil? ((if (postgres?) :fruit/appearance :FRUIT/appearance) row)))
|
||||||
|
(is (= 3 ((if (postgres?) :fruit/id :FRUIT/id) row)))
|
||||||
(is (= "Peach" ((if (postgres?) :fruit/name :FRUIT/name) row))))))
|
(is (= "Peach" ((if (postgres?) :fruit/name :FRUIT/name) row))))))
|
||||||
|
|
||||||
(deftest test-mapify
|
(deftest test-mapify
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue