22 lines
792 B
C++
22 lines
792 B
C++
// Route: POST /validate/user (all-failures validation error)
|
|||
|
|
#include "support/Assert.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
Fixture f;
|
||
|
|
auto ok = f.client->post(
|
||
|
|
"/validate/user",
|
||
|
|
"{\"username\":\"ada\",\"email\":\"ada@x.io\",\"age\":\"36\"}",
|
||
|
|
"application/json");
|
||
|
|
check(ok.status == 200, "valid model is 200");
|
||
|
|
auto bad = f.client->post("/validate/user",
|
||
|
|
"{\"username\":\"ad\",\"age\":\"old\"}",
|
||
|
|
"application/json");
|
||
|
|
check(bad.status == 422, "invalid model is 422");
|
||
|
|
check(contains(bad.body, "username"), "username failure listed");
|
||
|
|
check(contains(bad.body, "email"), "missing email listed");
|
||
|
|
check(contains(bad.body, "age"), "bad age listed");
|
||
|
|
return finish("validate/user");
|
||
|
|
}
|