Update tests & CHANGELOG

This commit is contained in:
Tommi Reiman 2020-04-06 10:57:12 +03:00
parent 3e386c930d
commit c5dc91af89
2 changed files with 48 additions and 1 deletions

View file

@ -20,6 +20,14 @@ We use [Break Versioning][breakver]. The version numbers follow a `<major>.<mino
is called the first time, so that `rfe/push-state` and such can be called
([#315](https://github.com/metosin/reitit/issues/315))
### `reitit-malli`
* Update malli to latest version:
```clj
[metosin/malli "0.0.1-20200404.091302-14"] is available but we use "0.0.1-20200305.102752-13"
```
## 0.4.2 (2020-01-17)
### `reitit`

View file

@ -330,7 +330,46 @@
(testing "open: keys are NOT stripped"
(is (= {:status 200, :body {:x 1, :request true, :response true}}
(app (->request "open")))))))))))
(app (->request "open")))))))))
(testing "sequence schemas"
(let [app (ring/ring-handler
(ring/router
["/ping" {:get {:parameters {:body [:vector [:map [:message string?]]]}
:responses {200 {:body [:vector [:map [:pong string?]]]}
501 {:body [:vector [:map [:error string?]]]}}
:handler (fn [{{[{:keys [message]}] :body} :parameters :as req}]
(condp = message
"ping" {:status 200
:body [{:pong message}]}
"fail" {:status 501
:body [{:error "fail"}]}
{:status 200
:body {:invalid "response"}}))}}]
{:data {:middleware [rrc/coerce-exceptions-middleware
rrc/coerce-request-middleware
rrc/coerce-response-middleware]
:coercion malli/coercion}}))
->request (fn [body]
{:uri "/ping"
:request-method :get
:muuntaja/request {:format "application/json"}
:body-params body})]
(testing "succesfull request"
(let [{:keys [status body]} (app (->request [{:message "ping"}]))]
(is (= 200 status))
(is (= [{:pong "ping"}] body)))
(testing "succesfull failure"
(let [{:keys [status body]} (app (->request [{:message "fail"}]))]
(is (= 501 status))
(is (= [{:error "fail"}] body))))
(testing "failed response"
(let [{:keys [status body]} (app (->request [{:message "kosh"}]))]
(is (= 500 status))
(is (= :reitit.coercion/response-coercion (:type body))))))))))
#?(:clj
(deftest muuntaja-test