Files
moloapp/tests/example/operability/deadline_test.cpp
T
retoorandClaude Sonnet 5.5 62fdd08da8 feat(workflow): example covers security, platform, enterprise and resilience features
105 route tests, matrix crawl, spec and README updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 02:19:52 +02:00

23 lines
1.2 KiB
C++

// 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");
}