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 { describe, expect, it } from "vitest";
import { mergeQueryMessages } from "../../apps/desktop/src/lib/query/queryResultMessages";
import type { QueryMessage } from "../../apps/desktop/src/types/database";
import { hasQueryOutput } from "../../apps/desktop/src/lib/query/queryOutput";

const notice: QueryMessage = { severity: "NOTICE", message: "same", code: "00000" };

describe("streamed query messages", () => {
  it("does not duplicate streamed messages in the completed response", () => {
    expect(mergeQueryMessages([notice, notice], [notice, notice])).toEqual([notice, notice]);
  });

  it("preserves repeated occurrences and messages from other drivers", () => {
    const warning = { severity: "WARNING", message: "other" };
    expect(mergeQueryMessages([notice], [notice, notice, warning])).toEqual([notice, notice, warning]);
  });

  it("retains messages when execution returns no successful result", () => {
    expect(mergeQueryMessages([notice], [])).toEqual([notice]);
    expect(hasQueryOutput({ liveQueryMessages: [notice] })).toBe(true);
  });

  it("normalizes optional fields while keeping different details distinct", () => {
    const detailed = { ...notice, detail: "context" };
    expect(mergeQueryMessages([notice], [{ ...notice, hint: undefined }, detailed])).toEqual([notice, detailed]);
  });
});