// Route: /operability/deadline (budget shared across hops) #include "support/Assert.hpp" using namespace molo::example::test; using molo::example::fw::Method; static const char* kForm = "application/x-www-form-urlencoded"; int main() { Fixture f; check(f.client->get("/operability/deadline").status == 200, "status 200"); auto ok = f.client->post("/operability/deadline/run", "budget_ms=100&hops=3", kForm); check(contains(ok.body, "all hops finished in budget"), "fits in budget"); auto late = f.client->post("/operability/deadline/run", "budget_ms=70&hops=5", kForm); check(contains(late.body, "deadline exceeded at hop 3"), "expires at hop 3"); check(contains(late.body, "call skipped"), "side effect: log shows skipped hop"); auto bad = f.client->post("/operability/deadline/run", "budget_ms=99999&hops=0", kForm); check(bad.status == 422 && contains(bad.body, "must be between 0 and 5000"), "422 limit on budget"); auto json = f.client->request(Method::Post, "/operability/deadline/run", "{\"budget_ms\":\"abc\"}", {{"Content-Type", "application/json"}}); check(json.status == 422 && contains(json.headers.get("Content-Type"), "json"), "json client gets json error"); return finish("operability/deadline"); }