Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

1.3 KB
Raw Blame
import { test } from "vitest";
import assert from "node:assert/strict";
import { buildSqlServerDatabaseTreeNodes } from "../../apps/desktop/src/lib/database/sqlServerTree.ts";

test("SQL Server database tree shows schemas before objects", () => {
  const nodes = buildSqlServerDatabaseTreeNodes("conn", "app", ["dbo", "zeta", "sales"]);

  const topLevel = nodes.map((n) => ({ id: n.id, label: n.label, type: n.type }));
  assert.deepEqual(topLevel, [
    { id: "conn:app:dbo", label: "dbo", type: "schema" },
    { id: "conn:app:sales", label: "sales", type: "schema" },
    { id: "conn:app:zeta", label: "zeta", type: "schema" },
  ]);
});

test("SQL Server database tree keeps dbo when no other schemas exist", () => {
  const nodes = buildSqlServerDatabaseTreeNodes("conn", "app", ["dbo"]);

  assert.deepEqual(
    nodes.map((node) => ({ id: node.id, label: node.label, type: node.type })),
    [{ id: "conn:app:dbo", label: "dbo", type: "schema" }],
  );
});

test("SQL Server database tree includes cdc schema", () => {
  const nodes = buildSqlServerDatabaseTreeNodes("conn", "app", ["dbo", "cdc"]);

  assert.deepEqual(
    nodes.map((node) => ({ id: node.id, label: node.label, type: node.type })),
    [
      { id: "conn:app:cdc", label: "cdc", type: "schema" },
      { id: "conn:app:dbo", label: "dbo", type: "schema" },
    ],
  );
});