同步完整源码至远程:扁平化重构现状 + 未入库源文件
- 补入库: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)与签名私钥仍按规则排除
This commit is contained in:
1 parent
5c0be49217
commit
2c0bfafd8d
269 files changed
+10372
-16435
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
describe("桌面后端引导", () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
it("使用 sidecar 注入的动态地址和令牌,不回退到 8788", async () => {
|
||||
const fetcher = vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({ service: "opsxdb", version: "0.1.0" }),
|
||||
});
|
||||
vi.stubGlobal("window", {
|
||||
__OPSXDB_API__: "http://127.0.0.1:49123",
|
||||
__OPSXDB_TOKEN__: "local-test-token",
|
||||
location: { protocol: "tauri:", hostname: "tauri.localhost", port: "" },
|
||||
});
|
||||
vi.stubGlobal("fetch", fetcher);
|
||||
vi.resetModules();
|
||||
const { health } = await import("./api");
|
||||
await health();
|
||||
expect(fetcher).toHaveBeenCalledWith("http://127.0.0.1:49123/api/health", {
|
||||
headers: { Authorization: "Bearer local-test-token" },
|
||||
});
|
||||
});
|
||||
|
||||
it("其他项目占用目标地址时拒绝将其当作 OpsxDB", async () => {
|
||||
vi.stubGlobal("window", {
|
||||
__OPSXDB_API__: "http://127.0.0.1:8788",
|
||||
location: { protocol: "tauri:", hostname: "tauri.localhost", port: "" },
|
||||
});
|
||||
vi.stubGlobal("fetch", vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({ service: "opsxapi" }),
|
||||
}));
|
||||
vi.resetModules();
|
||||
const { health } = await import("./api");
|
||||
await expect(health()).rejects.toThrow("不是 OpsxDB 后端");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user