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

22 lines
1.5 KiB
C++
Raw Normal View History

// Route: POST /agent/runtime/operation and /agent/runtime/async
#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);
auto op = f.client->post("/agent/runtime/operation", "{\"name\":\"projects/p/locations/l/operations/1\"}", "application/json");
check(op.status == 503 && contains(op.body, "google_not_configured"), "operation: no credential is 503");
check(f.client->post("/agent/runtime/operation", "{\"name\":\"../etc\"}", "application/json").status == 422, "operation: bad name is 422");
check(f.client->post("/agent/runtime/operation", "{}", "application/json").status == 422, "operation: missing name is 422");
auto as = f.client->post("/agent/runtime/async", "{\"id\":\"1\",\"inputGcsUri\":\"gs://in/q.json\",\"outputGcsUri\":\"gs://out/r.json\"}", "application/json");
check(as.status == 503 && contains(as.body, "google_not_configured"), "async: no credential is 503");
check(f.client->post("/agent/runtime/async", "{\"id\":\"1\",\"inputGcsUri\":\"http://x\",\"outputGcsUri\":\"gs://o\"}", "application/json").status == 422, "async: non gs uri is 422");
check(f.client->get("/agent/runtime/operation").status == 405, "operation: get is 405");
check(f.client->get("/agent/runtime/async").status == 405, "async: get is 405");
check(rig.mock->send_count() == 0, "nothing reached Google");
return finish("agent/runtime/operation");
}