http サービスをテストするために ring.mock.requests ライブラリを使用しようとしています。私はこのビットのコードを持っています
(auth-routes
(->
(mock/request :post "/auth/user")
(mock/body {:username "user" :password "pass"})
(mock/content-type "application/json")))
thread-first マクロの内部部分は正しく動作しているように見えますが、auth-routes にモック リクエストを作成しようとすると失敗します。
そして、これが私のルートです:
(def auth-routes
(context "/auth" []
:tags ["Authentication"]
(POST "/user" []
:return s/Uuid
:body [request m/User]
:summary "Create new user"
(ok (auth/create-user request)))) ...)
これは私のスキーマです:
(def User {:username s/Str
:password s/Str})
私が見ている例外は
clojure.lang.ExceptionInfo
Request validation failed
{:error (not (map? nil)), :type :compojure.api.exception/request-validation}
私のルートはnil
体のようになっているようで、そこにいることを期待{:username "user" :password "pass"}
しています。
私は何を間違っていますか?このルートにボディを渡すにはどうすればよいですか?