Files
moloapp/tests/example/agent/runtime/create_test.cpp
T

22 lines
1.6 KiB
C++

// Route: POST /agent/runtime/create (starts the operation, never waits)
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
GoogleRig rig(false);
Fixture f(rig.client);
std::string ok = "{\"displayName\":\"Agent\",\"agentFramework\":\"google-adk\",\"imageUri\":\"us-docker.pkg.dev/p/r/a:1\",\"maxInstances\":10,\"cpu\":\"4\",\"memory\":\"8Gi\"}";
auto res = f.client->post("/agent/runtime/create", ok, "application/json");
check(res.status == 503 && contains(res.body, "google_not_configured"), "no credential is 503");
check(f.client->post("/agent/runtime/create", "{}", "application/json").status == 422, "missing displayName is 422");
check(f.client->post("/agent/runtime/create", "{\"displayName\":\"a\",\"maxInstances\":5000}", "application/json").status == 422, "maxInstances over 1000 is 422");
check(f.client->post("/agent/runtime/create", "{\"displayName\":\"a\",\"cpu\":\"3\"}", "application/json").status == 422, "cpu 3 is 422");
check(f.client->post("/agent/runtime/create", "{\"displayName\":\"a\",\"identityType\":\"AGENT_IDENTITY\",\"serviceAccount\":\"a@b.c\"}", "application/json").status == 422, "agent identity with service account is 422");
check(f.client->post("/agent/runtime/create", "{\"displayName\":\"a\",\"agentFramework\":\"magic\"}", "application/json").status == 422, "unknown framework is 422");
check(f.client->get("/agent/runtime/create").status == 405, "get is 405");
check(rig.mock->send_count() == 0, "nothing reached Google");
return finish("agent/runtime/create");
}