// Route: POST /agent/optimize/suggest (cluster failures, suggest an instruction) #include "support/GoogleRig.hpp" using namespace molo::example::test; int main() { const char* json = "application/json"; GoogleRig keyed; Fixture f(keyed.client); check(f.client->post("/agent/optimize/suggest", "{\"failures\":\"x\"}", json).status == 422, "missing instruction is 422"); check(f.client->post("/agent/optimize/suggest", "{\"instruction\":\"be nice\"}", json).status == 422, "missing failures is 422"); check(f.client->post("/agent/optimize/suggest", "{\"instruction\":\"" + std::string(8001, 'x') + "\",\"failures\":\"x\"}", json) .status == 422, "instruction over the 8000 character cap is 422"); check(keyed.mock->send_count() == 0, "rejected input never reached Google"); check(f.client->get("/agent/optimize/suggest").status == 405, "get is 405"); GoogleRig none(false); Fixture g(none.client); auto res = g.client->post("/agent/optimize/suggest", "{\"instruction\":\"be nice\",\"failures\":\"rude reply\"}", 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/suggest"); }