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.7 KB
Raw Blame
import { describe, expect, it } from "vitest";
import { quickConnectionOpenTarget } from "@/lib/connection/connectionOpenTarget";
import type { ConnectionConfig } from "@/types/database";

function connection(dbType: ConnectionConfig["db_type"]): ConnectionConfig {
  return {
    id: "conn",
    name: "conn",
    db_type: dbType,
    host: "127.0.0.1",
    port: 0,
    user: "",
    password: "",
    database: "",
    readonly: false,
    read_only: false,
    ssl_mode: "disabled",
    color: "#888",
  } as ConnectionConfig;
}

describe("quickConnectionOpenTarget", () => {
  it("opens message queue connections in the MQ admin console", () => {
    expect(quickConnectionOpenTarget(connection("mq"))).toEqual({ kind: "mq-admin" });
  });

  it("opens Nacos connections in the Nacos admin console", () => {
    expect(quickConnectionOpenTarget(connection("nacos"))).toEqual({ kind: "nacos-admin" });
  });

  it("opens Etcd connections in the key browser", () => {
    expect(quickConnectionOpenTarget(connection("etcd"))).toEqual({ kind: "etcd" });
  });

  it("opens ZooKeeper connections in the key browser", () => {
    expect(quickConnectionOpenTarget(connection("zookeeper"))).toEqual({ kind: "zookeeper" });
  });

  it("opens regular connections in a query tab", () => {
    expect(quickConnectionOpenTarget({ ...connection("postgresql"), database: "app" })).toEqual({
      kind: "query",
      database: "app",
    });
  });

  it("carries the connection's default schema into the query tab (#11844)", () => {
    expect(quickConnectionOpenTarget({ ...connection("oracle"), database: "XE", default_schema: "REPORTING" })).toEqual({
      kind: "query",
      database: "XE",
      schema: "REPORTING",
    });
  });
});