我正在尝试使用ring.mock.requests库来测试http服务。我有一段代码
(auth-routes
(->
(mock/request :post "/auth/user")
(mock/body {:username "user" :password "pass"})
(mock/content-type "application/json")))线程第一宏的内部部分似乎工作正常,但当我尝试向auth路由发出模拟请求时,它失败了。
这是我的路线:
(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"}在那里。
我做错了什么,怎么把身体送到这条路上?
https://stackoverflow.com/questions/37450374
复制相似问题