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 { firstZooKeeperEndpoint, normalizeZooKeeperConnectString } from "@/lib/zookeeper/zookeeperConnection";

describe("zookeeperConnection", () => {
  it("normalizes comma, semicolon, and newline separated connect strings", () => {
    expect(normalizeZooKeeperConnectString(" zk-1:2181, zk-2:2182\nzk-3 ; ")).toBe("zk-1:2181,zk-2:2182,zk-3");
  });

  it("extracts the first host and port from a connect string", () => {
    expect(firstZooKeeperEndpoint("zk-1:2182,zk-2:2181")).toEqual({ host: "zk-1", port: 2182 });
  });

  it("strips a zookeeper URL scheme when normalizing connect strings", () => {
    expect(normalizeZooKeeperConnectString("zookeeper://zk-main:2181")).toBe("zk-main:2181");
  });

  it("uses the ZooKeeper default port when the first endpoint omits a port", () => {
    expect(firstZooKeeperEndpoint("zk-main")).toEqual({ host: "zk-main", port: 2181 });
  });

  it("parses bracketed IPv6 endpoints", () => {
    expect(firstZooKeeperEndpoint("[::1]:2281,zk-2:2181")).toEqual({ host: "::1", port: 2281 });
  });
});