Fork me on GitHub
#yada
<
2018-07-30
>
fiddlerwoaroof17:07:11

I've been trying to use response-for to test a POST resource. When I specify :form for parameters in the resource, the test works but it doesn't work if I specify :body.

fiddlerwoaroof17:07:42

My resource definition looks like:

(yada/resource
   {:methods
    :post {:parameters {:form {s/Keyword s/Any}}
           :consumes "application/json"
           :produces "application/json"
           :response (post-user-settings-response-fn user-settings-storage)}}})

fiddlerwoaroof17:07:37

A test looks like:

(is (= 200
       (-> (response-for resource :post "/"
                         {:headers {"Content-Type" "application/json"}
                          :body (.getBytes (json/encode expected-settings))})
           :status)))

fiddlerwoaroof17:07:09

However, this test is failing because I'm getting a 400 saying that the resource expects a body