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

21 lines
1.1 KiB
C++

// Route: POST /agent/runtime/query and /agent/runtime/stream
#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);
for (std::string route : {"/agent/runtime/query", "/agent/runtime/stream"}) {
auto res = f.client->post(route, "{\"id\":\"123\",\"input\":{\"message\":\"hi\"}}", "application/json");
check(res.status == 503 && contains(res.body, "google_not_configured"), route + " no credential is 503");
check(f.client->post(route, "{\"input\":{}}", "application/json").status == 422, route + " missing id is 422");
check(f.client->post(route, "{\"id\":\"1\",\"input\":\"text\"}", "application/json").status == 422, route + " non-object input is 422");
check(f.client->post(route, "{\"id\":\"1\",\"classMethod\":\"bad method\"}", "application/json").status == 422, route + " bad classMethod is 422");
check(f.client->get(route).status == 405, route + " get is 405");
}
check(rig.mock->send_count() == 0, "nothing reached Google");
return finish("agent/runtime/query");
}