I'm doing tests on my luminus application and I want to test my post fuction as below. However, the data is posted on the body of the request object as a byte input stream. How do i make the data to be posted on the params key of the request object? I got this example from this link http://www.jarrodctaylor.com/posts/Compojure-Address-Book-Part-1/
(defn example-post [request]
(let [post-value (get-in request [:params :example-post])]
(str "You posted: " post-value)))
(fact "Test POST"
(let [response (app (mock/request :post "/post" {:example-post "Some data"}))]
(:status response) => 200
(:body response) => "You posted: Some data")))
Got the answer, I was binding the mock/request in the ring handler function defroutes app-routes as opposed to the app var:
The correct way:
Incorrect way