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}]
|
||||
(let [[top childs] (ring/group-keys data)
|
||||
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}))
|
||||
compile (fn [[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}]
|
||||
(let [[top childs] (group-keys data)
|
||||
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}))
|
||||
->endpoint (fn [p d m s]
|
||||
(-> (middleware/compile-result [p d] opts s)
|
||||
|
|
|
|||
|
|
@ -20,14 +20,8 @@
|
|||
(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/merge
|
||||
::endpoint
|
||||
(s/map-of #{:get :head :post :put :delete :connect :options :trace :patch} map?)))
|
||||
(s/keys :opt-un [::rs/handler ::rs/name ::rs/no-doc ::middleware]))
|
||||
|
||||
;;
|
||||
;; Validator
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@
|
|||
(testing "with default spec validates :name, :handler and :middleware"
|
||||
(is (thrown-with-msg?
|
||||
ExceptionInfo
|
||||
#":reitit.ring.spec/invalid-route-data"
|
||||
#"Invalid route data"
|
||||
(ring/router
|
||||
["/api" {:handler "identity"}]
|
||||
{:validate rrs/validate})))
|
||||
(is (thrown-with-msg?
|
||||
ExceptionInfo
|
||||
#":reitit.ring.spec/invalid-route-data"
|
||||
#"Invalid route data"
|
||||
(ring/router
|
||||
["/api" {:handler identity
|
||||
:name "kikka"}]
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
(testing "all endpoints are validated"
|
||||
(is (thrown-with-msg?
|
||||
ExceptionInfo
|
||||
#":reitit.ring.spec/invalid-route-data"
|
||||
#"Invalid route data"
|
||||
(ring/router
|
||||
["/api" {:patch {:handler "identity"}}]
|
||||
{:validate rrs/validate}))))
|
||||
|
|
@ -69,7 +69,7 @@
|
|||
(handler request)))}]}})))
|
||||
(is (thrown-with-msg?
|
||||
ExceptionInfo
|
||||
#":reitit.ring.spec/invalid-route-data"
|
||||
#"Invalid route data"
|
||||
(ring/router
|
||||
["/api" {:get {:handler identity
|
||||
:roles #{:adminz}}}]
|
||||
|
|
@ -113,7 +113,7 @@
|
|||
|
||||
(is (thrown-with-msg?
|
||||
ExceptionInfo
|
||||
#":reitit.ring.spec/invalid-route-data"
|
||||
#"Invalid route data"
|
||||
(ring/router
|
||||
["/api"
|
||||
["/plus/:e"
|
||||
|
|
|
|||
Loading…
Reference in a new issue