26 lines
1.5 KiB
C++
26 lines
1.5 KiB
C++
// Routes: GET /google/cloudai, /google/cloudai/status, /google/cloudai/calls
|
|||
|
|
#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 page = f.client->get("/google/cloudai");
|
||
|
|
check(page.status == 200, "page 200 without a credential");
|
||
|
|
check(contains(page.headers.get("Content-Type"), "text/html"), "html");
|
||
|
|
check(contains(page.body, "Cloud AI") && contains(page.body, "viewport"), "page and mobile viewport");
|
||
|
|
check(contains(page.body, "/embedded/google_cloudai.js"), "script wired");
|
||
|
|
auto status = f.client->get("/google/cloudai/status");
|
||
|
|
check(status.status == 200 && contains(status.body, "\"configured\":false"), "status without credential");
|
||
|
|
check(contains(status.body, "documentai v1") && contains(status.body, "mediatranslation"), "lists apis and the gap");
|
||
|
|
auto calls = f.client->get("/google/cloudai/calls");
|
||
|
|
check(calls.status == 200 && contains(calls.body, "translate.projects.locations.translateText"), "call table");
|
||
|
|
check(contains(calls.body, "documentai.projects.locations.processors.process"), "document ai rows");
|
||
|
|
check(f.client->post("/google/cloudai", "{}", "application/json").status == 405, "post page is 405");
|
||
|
|
check(f.client->post("/google/cloudai/status", "{}", "application/json").status == 405, "post status is 405");
|
||
|
|
check(rig.mock->send_count() == 0, "no network");
|
||
|
|
return finish("google/cloudai/page");
|
||
|
|
}
|