mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 00:11:11 +00:00
Add coercion tests for vector data-specs, 0.2.9
This commit is contained in:
parent
8dc1e50c44
commit
ed1c2b0c4f
2 changed files with 12 additions and 6 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
## 0.2.9 (2018-11-21)
|
||||||
|
|
||||||
|
## `reitit-spec`
|
||||||
|
|
||||||
|
* support for vector data-specs for request & response parameters by [Heikki Hämäläinen](https://github.com/hjhamala).
|
||||||
|
|
||||||
## 0.2.8 (2018-11-18)
|
## 0.2.8 (2018-11-18)
|
||||||
|
|
||||||
## `reitit-core`
|
## `reitit-core`
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@
|
||||||
[["/schema" {:coercion reitit.coercion.schema/coercion}
|
[["/schema" {:coercion reitit.coercion.schema/coercion}
|
||||||
["/:number/:keyword" {:parameters {:path {:number s/Int
|
["/:number/:keyword" {:parameters {:path {:number s/Int
|
||||||
:keyword s/Keyword}
|
:keyword s/Keyword}
|
||||||
:query (s/maybe {:int s/Int})}}]]
|
:query (s/maybe {:int s/Int, :ints [s/Int]})}}]]
|
||||||
["/spec" {:coercion reitit.coercion.spec/coercion}
|
["/spec" {:coercion reitit.coercion.spec/coercion}
|
||||||
["/:number/:keyword" {:parameters {:path {:number int?
|
["/:number/:keyword" {:parameters {:path {:number int?
|
||||||
:keyword keyword?}
|
:keyword keyword?}
|
||||||
:query (ds/maybe {:int int?})}}]]
|
:query (ds/maybe {:int int?, :ints [int?]})}}]]
|
||||||
["/none"
|
["/none"
|
||||||
["/:number/:keyword" {:parameters {:path {:number int?
|
["/:number/:keyword" {:parameters {:path {:number int?
|
||||||
:keyword keyword?}}}]]]
|
:keyword keyword?}}}]]]
|
||||||
|
|
@ -30,8 +30,8 @@
|
||||||
(is (= {:path {:keyword :abba, :number 1}, :query nil}
|
(is (= {:path {:keyword :abba, :number 1}, :query nil}
|
||||||
(coercion/coerce! m))))
|
(coercion/coerce! m))))
|
||||||
(let [m (r/match-by-path r "/schema/1/abba")]
|
(let [m (r/match-by-path r "/schema/1/abba")]
|
||||||
(is (= {:path {:keyword :abba, :number 1}, :query {:int 10}}
|
(is (= {:path {:keyword :abba, :number 1}, :query {:int 10, :ints [1,2,3]}}
|
||||||
(coercion/coerce! (assoc m :query-params {:int "10"}))))))
|
(coercion/coerce! (assoc m :query-params {"int" "10", "ints" ["1" "2" "3"]}))))))
|
||||||
(testing "throws with invalid input"
|
(testing "throws with invalid input"
|
||||||
(let [m (r/match-by-path r "/schema/kikka/abba")]
|
(let [m (r/match-by-path r "/schema/kikka/abba")]
|
||||||
(is (thrown? ExceptionInfo (coercion/coerce! m))))))
|
(is (thrown? ExceptionInfo (coercion/coerce! m))))))
|
||||||
|
|
@ -42,8 +42,8 @@
|
||||||
(is (= {:path {:keyword :abba, :number 1}, :query nil}
|
(is (= {:path {:keyword :abba, :number 1}, :query nil}
|
||||||
(coercion/coerce! m))))
|
(coercion/coerce! m))))
|
||||||
(let [m (r/match-by-path r "/schema/1/abba")]
|
(let [m (r/match-by-path r "/schema/1/abba")]
|
||||||
(is (= {:path {:keyword :abba, :number 1}, :query {:int 10}}
|
(is (= {:path {:keyword :abba, :number 1}, :query {:int 10, :ints [1,2,3]}}
|
||||||
(coercion/coerce! (assoc m :query-params {:int "10"}))))))
|
(coercion/coerce! (assoc m :query-params {"int" "10", "ints" ["1" "2" "3"]}))))))
|
||||||
(testing "throws with invalid input"
|
(testing "throws with invalid input"
|
||||||
(let [m (r/match-by-path r "/spec/kikka/abba")]
|
(let [m (r/match-by-path r "/spec/kikka/abba")]
|
||||||
(is (thrown? ExceptionInfo (coercion/coerce! m))))))
|
(is (thrown? ExceptionInfo (coercion/coerce! m))))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue