Files
moloapp/tests/example/agent/adk/run_test.cpp
T

30 lines
1.5 KiB
C++
Raw Normal View History

// Route: POST /agent/adk/run (validation and credential gate; the model call
// itself is proven live in the google suite, not scripted here)
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
GoogleRig none(false);
Fixture f(none.client);
auto post = [&](const std::string& body) {
return f.client->post("/agent/adk/run", body, "application/json");
};
auto ok = post("{\"prompt\":\"total of 2 and 3?\",\"template\":\"financial_analysis\"}");
check(ok.status == 503 && contains(ok.body, "google_not_configured"), "no credential is a loud 503");
check(post("not json").status == 422, "bad json is 422");
check(post("{\"prompt\":\"\"}").status == 422, "empty prompt is 422");
check(post("{\"prompt\":\"" + std::string(2001, 'x') + "\"}").status == 422, "prompt over cap is 422");
check(post("{\"prompt\":\"hi\",\"template\":\"nope\"}").status == 422, "unknown template is 422");
check(none.mock->send_count() == 0, "side effect: nothing sent without a credential");
GoogleRig keyed;
Fixture g(keyed.client);
check(g.client->post("/agent/adk/run", "{\"prompt\":\"\"}", "application/json").status == 422,
"validation also runs with a credential");
check(g.client->post("/agent/adk/run", "{\"prompt\":\"hi\",\"cid\":\"bad id!\"}", "application/json").status == 422,
"bad session id is 422");
check(keyed.mock->send_count() == 0, "rejected input never reached Google");
return finish("agent/adk run");
}