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 { describe, expect, it } from "vitest";
import { buildEtcdKeyTree, flattenVisibleEtcdKeyTree } from "@/lib/etcd/etcdKeyTree";
describe("etcd key tree", () => {
it("groups slash-delimited keys", () => {
const tree = buildEtcdKeyTree([
{ key: "/app/config/name", modRevision: 3 },
{ key: "/app/config/env", modRevision: 4 },
{ key: "/service/api", modRevision: 5 },
]);
expect(tree.map((node) => node.label)).toEqual(["/app", "/service"]);
const app = tree[0];
expect(app.kind).toBe("group");
if (app.kind === "group") {
expect(app.children.map((node) => node.label)).toEqual(["config"]);
}
});
it("flattens only expanded groups", () => {
const tree = buildEtcdKeyTree([{ key: "/app/config/name" }, { key: "/plain" }]);
const rows = flattenVisibleEtcdKeyTree(tree, new Set(["group:/app"]));
expect(rows.map((row) => `${row.depth}:${row.node.label}`)).toEqual(["0:/app", "1:config", "0:/plain"]);
});
it("keeps leading-slash and relative key prefixes in separate branches", () => {
const tree = buildEtcdKeyTree([{ key: "/test/ttt" }, { key: "test/app/config" }]);
expect(tree.map((node) => `${node.id}:${node.label}`)).toEqual(["group:/test:/test", "group:test:test"]);
});
});