// Route: POST /agent/optimize/scenarios (generateUserScenarios) #include #include "support/GoogleRig.hpp" using namespace molo::example::test; int main() { setenv("GOOGLE_CLOUD_PROJECT", "test-proj", 1); const char* json = "application/json"; GoogleRig keyed; Fixture f(keyed.client); check(f.client->post("/agent/optimize/scenarios", "{}", json).status == 422, "missing agent_instruction is 422"); check(f.client->post("/agent/optimize/scenarios", "{\"agent_instruction\":\"help\",\"count\":101}", json).status == 422, "count over the Google ceiling of 100 is 422"); check(f.client->post("/agent/optimize/scenarios", "{\"agent_instruction\":\"help\",\"count\":0}", json).status == 422, "count 0 is 422"); check(f.client->post("/agent/optimize/scenarios", "{\"agent_instruction\":\"help\",\"count\":\"many\"}", json).status == 422, "non-numeric count is 422"); check(keyed.mock->send_count() == 0, "rejected input never reached Google"); check(f.client->get("/agent/optimize/scenarios").status == 405, "get is 405"); GoogleRig none(false); Fixture g(none.client); auto res = g.client->post("/agent/optimize/scenarios", "{\"agent_instruction\":\"help\",\"count\":3}", json); check(res.status == 503 && contains(res.body, "google_not_configured"), "no credential is a loud 503"); check(none.mock->send_count() == 0, "no network without a credential"); return finish("agent/optimize/scenarios"); }