36 lines
1.6 KiB
C++
36 lines
1.6 KiB
C++
// Routes: GET /ai/deepseek (page), /status, /calls, /errors (no credential needed)
|
|
#include <cstdlib>
|
|
|
|
#include "support/Assert.hpp"
|
|
|
|
using namespace molo::example::test;
|
|
|
|
int main() {
|
|
setenv("MOLO_ENV_FILES", "off", 1);
|
|
unsetenv("DEEPSEEK_API_KEY");
|
|
Fixture f;
|
|
auto page = f.client->get("/ai/deepseek");
|
|
check(page.status == 200, "page 200");
|
|
check(contains(page.headers.get("Content-Type"), "text/html"), "html");
|
|
check(contains(page.body, "DeepSeek API") && contains(page.body, "viewport"), "title and mobile viewport");
|
|
check(contains(page.body, "/embedded/ai_deepseek.js"), "script wired");
|
|
check(f.client->post("/ai/deepseek", "{}", "application/json").status == 405, "post page is 405");
|
|
|
|
auto st = f.client->get("/ai/deepseek/status");
|
|
check(st.status == 200 && contains(st.body, "\"configured\":false"), "status without a key");
|
|
check(contains(st.body, "DEEPSEEK_API_KEY") && contains(st.body, "deepseek-flash") &&
|
|
contains(st.body, "deepseek-v4-pro"),
|
|
"status names credential env and models");
|
|
check(f.client->post("/ai/deepseek/status", "{}", "application/json").status == 405, "post status is 405");
|
|
|
|
auto calls = f.client->get("/ai/deepseek/calls");
|
|
check(calls.status == 200 && contains(calls.body, "/chat/completions") &&
|
|
contains(calls.body, "/beta/completions") && contains(calls.body, "/user/balance"),
|
|
"call table listed");
|
|
auto errors = f.client->get("/ai/deepseek/errors");
|
|
check(errors.status == 200 && contains(errors.body, "Insufficient Balance") &&
|
|
contains(errors.body, "\"retryable\":true"),
|
|
"error table listed");
|
|
return finish("ai/deepseek/page");
|
|
}
|