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.1 KB
Raw Blame
import { describe, expect, it } from "vitest";
import { parseGaussdbHosts, serializeGaussdbHosts } from "@/lib/connection/gaussdbHosts";

describe("GaussDB hosts", () => {
  it("keeps a single host and port in separate fields", () => {
    expect(serializeGaussdbHosts([{ host: "db.example.com", port: 5433 }])).toEqual({ host: "db.example.com", port: 5433 });
  });

  it("normalizes a legacy single host:port value", () => {
    expect(parseGaussdbHosts("db.example.com:5433", 5432)).toEqual([{ host: "db.example.com", port: 5433 }]);
  });

  it("serializes multiple hosts with embedded ports", () => {
    expect(
      serializeGaussdbHosts([
        { host: "db1", port: 5432 },
        { host: "db2", port: 5433 },
      ]),
    ).toEqual({ host: "db1:5432,db2:5433", port: 5432 });
  });

  it("round-trips bracketed IPv6 endpoints", () => {
    const entries = parseGaussdbHosts("[2001:db8::1]:5433,[2001:db8::2]:5434", 5432);
    expect(entries).toEqual([
      { host: "2001:db8::1", port: 5433 },
      { host: "2001:db8::2", port: 5434 },
    ]);
    expect(serializeGaussdbHosts(entries).host).toBe("[2001:db8::1]:5433,[2001:db8::2]:5434");
  });
});