Files
moloapp/tests/example/agent/optimize/runs_test.cpp
T

29 lines
1.1 KiB
C++
Raw Normal View History

// Route: POST /agent/optimize/runs (read-only list of evaluation runs)
#include <cstdlib>
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "test-proj", 1);
const char* json = "application/json";
GoogleRig keyed;
Fixture f(keyed.client);
check(f.client->post("/agent/optimize/runs", "{\"limit\":0}", json).status == 422,
"limit 0 is 422");
check(f.client->post("/agent/optimize/runs", "{\"limit\":101}", json).status == 422,
"limit over the page cap of 100 is 422");
check(f.client->post("/agent/optimize/runs", "[]", json).status == 422, "array body is 422");
check(keyed.mock->send_count() == 0, "rejected input never reached Google");
check(f.client->get("/agent/optimize/runs").status == 405, "get is 405");
GoogleRig none(false);
Fixture g(none.client);
auto res = g.client->post("/agent/optimize/runs", "{\"limit\":5}", 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/runs");
}