mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 08:21:11 +00:00
test: add test for overriding malli registry
This commit is contained in:
parent
ea58100fec
commit
af7313bd9b
1 changed files with 8 additions and 3 deletions
|
|
@ -585,7 +585,7 @@
|
||||||
(is (= {:status 200, :body {:total "FOO: this, BAR: that"}} (call m/schema custom-meta-merge-checking-schema)))
|
(is (= {:status 200, :body {:total "FOO: this, BAR: that"}} (call m/schema custom-meta-merge-checking-schema)))
|
||||||
(is (= {:status 200, :body {:total "FOO: this, BAR: that"}} (call identity custom-meta-merge-checking-parameters)))))
|
(is (= {:status 200, :body {:total "FOO: this, BAR: that"}} (call identity custom-meta-merge-checking-parameters)))))
|
||||||
|
|
||||||
(testing "options"
|
(testing "malli options"
|
||||||
(let [->app (fn [options]
|
(let [->app (fn [options]
|
||||||
(ring/ring-handler
|
(ring/ring-handler
|
||||||
(ring/router
|
(ring/router
|
||||||
|
|
@ -593,7 +593,7 @@
|
||||||
[:i :int]
|
[:i :int]
|
||||||
[:x :string]]}
|
[:x :string]]}
|
||||||
:handler (fn [{{:keys [body]} :parameters}]
|
:handler (fn [{{:keys [body]} :parameters}]
|
||||||
{:status 200 :body {}})}}]
|
{:status 200 :body body})}}]
|
||||||
{:data {:middleware [rrc/coerce-exceptions-middleware
|
{:data {:middleware [rrc/coerce-exceptions-middleware
|
||||||
rrc/coerce-request-middleware
|
rrc/coerce-request-middleware
|
||||||
rrc/coerce-response-middleware]
|
rrc/coerce-response-middleware]
|
||||||
|
|
@ -611,7 +611,12 @@
|
||||||
:malli.core/missing-key {:error/message {:en "MISSING"}}}}})
|
:malli.core/missing-key {:error/message {:en "MISSING"}}}}})
|
||||||
(assoc request :body-params {:i "x"}))
|
(assoc request :body-params {:i "x"}))
|
||||||
:body
|
:body
|
||||||
:humanized))))))))
|
:humanized))))
|
||||||
|
(testing "overriding registry"
|
||||||
|
(is (= {:body {:i "x" :x "x"} :status 200}
|
||||||
|
(-> ((->app {:options {:registry (merge (m/default-schemas)
|
||||||
|
{:int :string})}})
|
||||||
|
(assoc request :body-params {:i "x" :x "x"}))))))))))
|
||||||
|
|
||||||
#?(:clj
|
#?(:clj
|
||||||
(deftest per-content-type-test
|
(deftest per-content-type-test
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue