mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 00:11:11 +00:00
Fix tests
This commit is contained in:
parent
c8eaa955c3
commit
c3de6ff3dd
6 changed files with 12 additions and 18 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
(defn compile-result [[path data] {:keys [::default-options-handler] :as opts}]
|
(defn compile-result [[path data] {:keys [::default-options-handler] :as opts}]
|
||||||
(let [[top childs] (ring/group-keys data)
|
(let [[top childs] (ring/group-keys data)
|
||||||
childs (cond-> childs
|
childs (cond-> childs
|
||||||
(and (not (:options childs)) default-options-handler)
|
(and (not (:options childs)) (not (:handler top)) default-options-handler)
|
||||||
(assoc :options {:no-doc true, :handler default-options-handler}))
|
(assoc :options {:no-doc true, :handler default-options-handler}))
|
||||||
compile (fn [[path data] opts scope]
|
compile (fn [[path data] opts scope]
|
||||||
(interceptor/compile-result [path data] opts scope))
|
(interceptor/compile-result [path data] opts scope))
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
(defn compile-result [[path data] {:keys [::default-options-handler] :as opts}]
|
(defn compile-result [[path data] {:keys [::default-options-handler] :as opts}]
|
||||||
(let [[top childs] (group-keys data)
|
(let [[top childs] (group-keys data)
|
||||||
childs (cond-> childs
|
childs (cond-> childs
|
||||||
(and (not (:options childs)) default-options-handler)
|
(and (not (:options childs)) (not (:handler top)) default-options-handler)
|
||||||
(assoc :options {:no-doc true, :handler default-options-handler}))
|
(assoc :options {:no-doc true, :handler default-options-handler}))
|
||||||
->endpoint (fn [p d m s]
|
->endpoint (fn [p d m s]
|
||||||
(-> (middleware/compile-result [p d] opts s)
|
(-> (middleware/compile-result [p d] opts s)
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,8 @@
|
||||||
(s/def ::patch map?)
|
(s/def ::patch map?)
|
||||||
|
|
||||||
|
|
||||||
(s/def ::endpoint
|
|
||||||
(s/keys :req-un [::rs/handler]
|
|
||||||
:opt-un [::rs/name ::rs/no-doc ::middleware]))
|
|
||||||
|
|
||||||
(s/def ::data
|
(s/def ::data
|
||||||
(s/merge
|
(s/keys :opt-un [::rs/handler ::rs/name ::rs/no-doc ::middleware]))
|
||||||
::endpoint
|
|
||||||
(s/map-of #{:get :head :post :put :delete :connect :options :trace :patch} map?)))
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Validator
|
;; Validator
|
||||||
|
|
|
||||||
|
|
@ -495,11 +495,11 @@
|
||||||
(fn [{:keys [::r/router]}]
|
(fn [{:keys [::r/router]}]
|
||||||
(is router))
|
(is router))
|
||||||
{:executor sieppari/executor})
|
{:executor sieppari/executor})
|
||||||
{}))
|
{}))
|
||||||
(testing "3-arity"
|
(testing "3-arity"
|
||||||
((http/ring-handler
|
((http/ring-handler
|
||||||
(http/router [])
|
(http/router [])
|
||||||
(fn [{:keys [::r/router]}]
|
(fn [{:keys [::r/router]}]
|
||||||
(is router))
|
(is router))
|
||||||
{:executor sieppari/executor})
|
{:executor sieppari/executor})
|
||||||
{} ::respond ::raise)))
|
{} ::respond ::raise)))
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
(testing "with default spec validates :name, :handler and :middleware"
|
(testing "with default spec validates :name, :handler and :middleware"
|
||||||
(is (thrown-with-msg?
|
(is (thrown-with-msg?
|
||||||
ExceptionInfo
|
ExceptionInfo
|
||||||
#":reitit.ring.spec/invalid-route-data"
|
#"Invalid route data"
|
||||||
(ring/router
|
(ring/router
|
||||||
["/api" {:handler "identity"}]
|
["/api" {:handler "identity"}]
|
||||||
{:validate rrs/validate})))
|
{:validate rrs/validate})))
|
||||||
(is (thrown-with-msg?
|
(is (thrown-with-msg?
|
||||||
ExceptionInfo
|
ExceptionInfo
|
||||||
#":reitit.ring.spec/invalid-route-data"
|
#"Invalid route data"
|
||||||
(ring/router
|
(ring/router
|
||||||
["/api" {:handler identity
|
["/api" {:handler identity
|
||||||
:name "kikka"}]
|
:name "kikka"}]
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
(testing "all endpoints are validated"
|
(testing "all endpoints are validated"
|
||||||
(is (thrown-with-msg?
|
(is (thrown-with-msg?
|
||||||
ExceptionInfo
|
ExceptionInfo
|
||||||
#":reitit.ring.spec/invalid-route-data"
|
#"Invalid route data"
|
||||||
(ring/router
|
(ring/router
|
||||||
["/api" {:patch {:handler "identity"}}]
|
["/api" {:patch {:handler "identity"}}]
|
||||||
{:validate rrs/validate}))))
|
{:validate rrs/validate}))))
|
||||||
|
|
@ -69,7 +69,7 @@
|
||||||
(handler request)))}]}})))
|
(handler request)))}]}})))
|
||||||
(is (thrown-with-msg?
|
(is (thrown-with-msg?
|
||||||
ExceptionInfo
|
ExceptionInfo
|
||||||
#":reitit.ring.spec/invalid-route-data"
|
#"Invalid route data"
|
||||||
(ring/router
|
(ring/router
|
||||||
["/api" {:get {:handler identity
|
["/api" {:get {:handler identity
|
||||||
:roles #{:adminz}}}]
|
:roles #{:adminz}}}]
|
||||||
|
|
@ -113,7 +113,7 @@
|
||||||
|
|
||||||
(is (thrown-with-msg?
|
(is (thrown-with-msg?
|
||||||
ExceptionInfo
|
ExceptionInfo
|
||||||
#":reitit.ring.spec/invalid-route-data"
|
#"Invalid route data"
|
||||||
(ring/router
|
(ring/router
|
||||||
["/api"
|
["/api"
|
||||||
["/plus/:e"
|
["/plus/:e"
|
||||||
|
|
|
||||||
|
|
@ -570,10 +570,10 @@
|
||||||
(ring/router [])
|
(ring/router [])
|
||||||
(fn [{:keys [::r/router]}]
|
(fn [{:keys [::r/router]}]
|
||||||
(is router)))
|
(is router)))
|
||||||
{}))
|
{}))
|
||||||
(testing "3-arity"
|
(testing "3-arity"
|
||||||
((ring/ring-handler
|
((ring/ring-handler
|
||||||
(ring/router [])
|
(ring/router [])
|
||||||
(fn [{:keys [::r/router]} _ _]
|
(fn [{:keys [::r/router]} _ _]
|
||||||
(is router)))
|
(is router)))
|
||||||
{} ::respond ::raise)))
|
{} ::respond ::raise)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue