// Route: POST /doos/create (idempotent create with options) #include "support/Assert.hpp" #include "support/DoosHome.hpp" using namespace molo::example::test; int main() { ScratchDoosHome home("create"); Fixture f; auto first = f.client->post("/doos/create", "name=app1&size=1g", "application/x-www-form-urlencoded"); check(first.status == 200, "status 200"); check(contains(first.body, "\"created\":true"), "first create reports created"); auto again = f.client->post("/doos/create", "name=app1", "application/x-www-form-urlencoded"); check(contains(again.body, "\"created\":false"), "second create is idempotent"); auto noname = f.client->post("/doos/create", "size=1g", "application/x-www-form-urlencoded"); check(noname.status == 422, "missing name rejected"); auto badname = f.client->post("/doos/create", "name=Bad+Name", "application/x-www-form-urlencoded"); check(badname.status == 422, "bad name rejected"); auto badsize = f.client->post("/doos/create", "name=app2&size=1x", "application/x-www-form-urlencoded"); check(badsize.status == 422, "bad size rejected"); auto badnet = f.client->post("/doos/create", "name=app2&net=bogus", "application/x-www-form-urlencoded"); check(badnet.status == 422, "bad net rejected"); auto multi = f.client->post("/doos/create", "size=1x&net=bogus", "application/x-www-form-urlencoded"); check(multi.status == 422, "multi-failure is 422"); check(contains(multi.body, "name is required"), "all failures listed (name)"); check(contains(multi.body, "invalid size"), "all failures listed (size)"); return finish("doos/create"); }