Files
opsxdb/src/aiPresets.test.ts
T
logan 2c0bfafd8d 同步完整源码至远程:扁平化重构现状 + 未入库源文件
- 补入库:server/internal/db/dump.go、redis 分页/扫描预算测试、opsxdb-mcp main_test、
  packages/opsxdb-mcp package-lock、docs 审计与对比文档等 37 个新文件
- 含结构扁平化进行中的 80 处修改与 155 处旧结构删除(server/ src/ src-tauri/ 为当前有效源)
- 构建产物(bin/target/dist)与签名私钥仍按规则排除
2026-10-16 03:47:33 +08:00

32 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { AI_PRESETS, findAiPreset } from "./aiPresets";
describe("AI 预设表", () => {
it("id 唯一且包含本地与自定义兜底", () => {
const ids = AI_PRESETS.map((p) => p.id);
expect(new Set(ids).size).toBe(ids.length);
expect(findAiPreset("ollama")?.allowInsecureHttp).toBe(true);
expect(findAiPreset("custom")?.baseUrl).toBe("");
});
it("云端预设一律 https 且默认不放行 http", () => {
for (const p of AI_PRESETS.filter((x) => x.id !== "ollama" && x.id !== "custom")) {
expect(p.baseUrl.startsWith("https://"), p.id).toBe(true);
expect(p.allowInsecureHttp, p.id).toBe(false);
}
});
it("anthropic 协议与 x-api-key 配对,其余为 bearer/none", () => {
for (const p of AI_PRESETS) {
if (p.protocol === "anthropic") expect(p.authStyle, p.id).toBe("x-api-key");
else expect(["bearer", "none"], p.id).toContain(p.authStyle);
}
});
it("除自定义外默认模型都在模型清单中", () => {
for (const p of AI_PRESETS.filter((x) => x.id !== "custom")) {
expect(p.models, p.id).toContain(p.defaultModel);
}
});
});