25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
import { afterEach, describe, expect, it, vi } from "vitest";
const mocks = vi.hoisted(() => ({ invoke: vi.fn() }));
vi.mock("@tauri-apps/api/core", () => ({ invoke: mocks.invoke }));
afterEach(() => {
vi.unstubAllGlobals();
vi.clearAllMocks();
});
describe("offline Agent and standalone JRE import", () => {
it("returns separate driver and JRE counts from the desktop command", async () => {
const { importAgentsFromZip } = await import("../tauri");
mocks.invoke.mockResolvedValue({ count: 0, jreCount: 1 });
expect(await importAgentsFromZip("/tmp/renamed.tar.zst", "import-1")).toEqual({ count: 0, jreCount: 1 });
expect(mocks.invoke).toHaveBeenCalledWith("import_agents_from_zip", { path: "/tmp/renamed.tar.zst", operationId: "import-1" });
});
it("uploads standalone JRE packages and preserves both result counts", async () => {
const failures = [{ key: "21", is_jre: true, error: "Failed to extract JRE archive: Access is denied. (os error 5)" }];
const fetchMock = vi.fn().mockResolvedValue(new Response(JSON.stringify({ count: 0, jreCount: 1, failures })));
vi.stubGlobal("fetch", fetchMock);
const { importAgentsFromZip } = await import("../http");
const file = new File(["archive"], "renamed.tar.zst");
expect(await importAgentsFromZip(file, "import-2")).toEqual({ count: 0, jreCount: 1, failures });
const [url, request] = fetchMock.mock.calls[0];
expect(url).toContain("/api/agents/import-offline");
expect(request.method).toBe("POST");
expect(request.body.get("operationId")).toBe("import-2");
expect(request.body.get("file").name).toBe(file.name);
});
it("remains compatible with web backends that only return a driver count", async () => {
vi.stubGlobal("fetch", vi.fn().mockResolvedValue(new Response(JSON.stringify({ count: 2 }))));
const { importAgentsFromZip } = await import("../http");
// Older web backends report no per-item failures; the caller must still see an empty list.
expect(await importAgentsFromZip(new File(["archive"], "drivers.zip"))).toEqual({
count: 2,
jreCount: 0,
failures: [],
});
});
});