Files
moloapp/tests/example/ai/openai/platform/status_test.cpp
T

26 lines
1.4 KiB
C++
Raw Normal View History

// Routes: GET /ai/openai/platform, /status, /calls, /events
#include "support/Assert.hpp"
using namespace molo::example::test;
int main() {
setenv("MOLO_ENV_FILES", "off", 1);
unsetenv("OPENAI_API_KEY");
Fixture f;
auto page = f.client->get("/ai/openai/platform");
check(page.status == 200 && contains(page.body, "OpenAI platform"), "page 200");
check(contains(page.body, "ai_openai_platform.js"), "page loads its script");
auto st = f.client->get("/ai/openai/platform/status");
check(st.status == 200 && contains(st.body, "\"configured\":false"), "status without key");
check(contains(st.body, "\"credential_env\":\"OPENAI_API_KEY\""), "status names the env var");
check(contains(st.body, "\"calls\":188"), "status counts calls");
auto calls = f.client->get("/ai/openai/platform/calls");
check(calls.status == 200 && contains(calls.body, "createVectorStoreFileBatch"), "calls lists the table");
auto ev = f.client->get("/ai/openai/platform/events");
check(ev.status == 200 && contains(ev.body, "input_audio_buffer.append"), "events lists the catalog");
check(f.client->post("/ai/openai/platform/status", "{}", "application/json").status == 405, "post status is 405");
check(f.client->post("/ai/openai/platform", "{}", "application/json").status == 405, "post page is 405");
check(f.client->get("/ai/openai/platform/call").status == 405, "get call is 405");
return finish("ai/openai/platform/status");
}