Add regression test for swagger-spec 3arity handler

This commit is contained in:
Tommi Reiman 2018-11-17 21:25:40 +02:00
parent 8bb5755ced
commit cca55c5bd5

View file

@ -68,8 +68,8 @@
(testing "swagger-spec" (testing "swagger-spec"
(let [spec (:body (app (let [spec (:body (app
{:request-method :get {:request-method :get
:uri "/api/swagger.json"}))] :uri "/api/swagger.json"}))
(is (= {:x-id #{::math} expected {:x-id #{::math}
:swagger "2.0" :swagger "2.0"
:info {:title "my-api"} :info {:title "my-api"}
:paths {"/api/schema/plus/{z}" {:get {:parameters [{:description "" :paths {"/api/schema/plus/{z}" {:get {:parameters [{:description ""
@ -126,8 +126,15 @@
400 {:schema {:type "string"} 400 {:schema {:type "string"}
:description "kosh"} :description "kosh"}
500 {:description "fail"}} 500 {:description "fail"}}
:summary "plus"}}}} :summary "plus"}}}}]
spec))))) (is (= expected spec))
(testing "ring-async swagger-spec"
(let [response* (atom nil)
respond (partial reset! response*)]
(app {:request-method :get
:uri "/api/swagger.json"} respond (fn [_] (is false)))
(is (= expected (:body @response*))))))))
(defn spec-paths [app uri] (defn spec-paths [app uri]
(-> {:request-method :get, :uri uri} app :body :paths keys)) (-> {:request-method :get, :uri uri} app :body :paths keys))