yada

fiddlerwoaroof 2018-07-30T17:29:11.000102Z

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.

fiddlerwoaroof 2018-07-30T17:32:42.000426Z

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)}}})

fiddlerwoaroof 2018-07-30T17:35:37.000136Z

A test looks like:

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

fiddlerwoaroof 2018-07-30T17:36:09.000302Z

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