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 { beforeEach, describe, expect, it } from "vitest";
import { loadTimeoutInheritanceBackup, TIMEOUT_INHERITANCE_BACKUP_STORAGE_KEY } from "@/lib/connection/timeoutInheritanceBackup";

const storage = new Map<string, string>();
Object.defineProperty(globalThis, "localStorage", {
  configurable: true,
  value: {
    clear: () => storage.clear(),
    getItem: (key: string) => storage.get(key) ?? null,
    setItem: (key: string, value: string) => storage.set(key, value),
  },
});

describe("timeout inheritance backup", () => {
  beforeEach(() => localStorage.clear());

  it("preserves query timeouts up to one hour while connection timeouts remain capped at 300 seconds", () => {
    localStorage.setItem(
      TIMEOUT_INHERITANCE_BACKUP_STORAGE_KEY,
      JSON.stringify({
        version: 1,
        globalConnectTimeoutSecs: 301,
        globalQueryTimeoutSecs: 3600,
        connectSnapshots: { connection: 301 },
        querySnapshots: { longQuery: 3600, tooLong: 3601, unlimited: 0 },
      }),
    );

    expect(loadTimeoutInheritanceBackup()).toEqual({
      version: 1,
      globalConnectTimeoutSecs: 300,
      globalQueryTimeoutSecs: 3600,
      connectSnapshots: { connection: 300 },
      querySnapshots: { longQuery: 3600, tooLong: 3600, unlimited: 0 },
    });
  });
});