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.0 KB
Raw Blame
import { describe, expect, it } from "vitest";
import { elasticsearchJsonResponseForResult } from "@/lib/elasticsearch/elasticsearchJsonResponse";
import type { QueryResult } from "@/types/database";

const catJsonResult: QueryResult = {
  columns: ["status", "response"],
  rows: [[200, '[{"index":"data_pack_and_box_index_v1","docs.count":"42"}]']],
  affected_rows: 0,
  execution_time_ms: 1,
};

describe("Elasticsearch JSON response detection", () => {
  it("routes an unformatted CAT response to the JSON renderer", () => {
    expect(elasticsearchJsonResponseForResult("elasticsearch", "GET /_cat/indices/data_pack_and_box_index_v1", catJsonResult)).toEqual({
      status: 200,
      body: '[{"index":"data_pack_and_box_index_v1","docs.count":"42"}]',
    });
  });

  it("routes Easysearch REST responses through the same JSON renderer", () => {
    expect(elasticsearchJsonResponseForResult("easysearch", "GET /_cat/indices", catJsonResult)).toEqual({
      status: 200,
      body: '[{"index":"data_pack_and_box_index_v1","docs.count":"42"}]',
    });
  });
});