Files

33 lines
1.2 KiB
C++
Raw Permalink Normal View History

// Route: GET /google/status (credential state and known Google services)
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
{
GoogleRig rig;
Fixture f(rig.client);
auto res = f.client->get("/google/status");
check(res.status == 200, "status 200");
check(contains(res.headers.get("Content-Type"), "application/json"), "json");
check(contains(res.body, "\"configured\":true"), "configured with a key");
check(contains(res.body, "\"name\":\"texttospeech\"") &&
contains(res.body, "\"name\":\"speech\"") &&
contains(res.body, "\"name\":\"generativelanguage\""),
"lists the known services");
check(contains(res.body, "https://texttospeech.googleapis.com/v1"),
"base urls shown");
check(!contains(res.body, kTestKey), "credential never shown");
check(rig.mock->send_count() == 0, "side effect: no upstream traffic");
}
{
GoogleRig rig(false);
Fixture f(rig.client);
check(contains(f.client->get("/google/status").body, "\"configured\":false"),
"not configured without a key");
}
Fixture f;
check(f.client->post("/google/status").status == 405, "post is 405");
return finish("google/status");
}