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.6 KB
Raw Blame
import { describe, expect, it } from "vitest";

import type { InstalledPlugin } from "@/types/database";
import { installedPluginOffersExternalMcp, installedPluginProvidesMcpTools, marketplacePluginProvidesMcpTools } from "@/lib/plugins/pluginMcpMark";

function plugin(manifest: Partial<InstalledPlugin["manifest"]>): Pick<InstalledPlugin, "manifest"> {
  return { manifest: { id: "io.dbx.x", name: "X", version: "1.0.0", ...manifest } as InstalledPlugin["manifest"] };
}

const backend = { backend: { executable: "bin/x" } };

describe("plugin MCP mark", () => {
  it("is carried by plugins with a backend and an mcp contribution", () => {
    expect(installedPluginProvidesMcpTools(plugin({ entrypoints: backend, contributions: [{ type: "mcp", id: "x.mcp" }] }))).toBe(true);
    expect(installedPluginProvidesMcpTools(plugin({ entrypoints: backend, contributions: [] }))).toBe(false);
    expect(installedPluginProvidesMcpTools(plugin({ contributions: [{ type: "mcp", id: "x.mcp" }] }))).toBe(false);
    expect(installedPluginProvidesMcpTools(plugin({}))).toBe(false);
  });

  it("separates the mark from the author's external opt-in", () => {
    const marked = plugin({ entrypoints: backend, contributions: [{ type: "mcp", id: "x.mcp" }] });
    expect(installedPluginOffersExternalMcp(marked)).toBe(false);
    expect(installedPluginOffersExternalMcp(plugin({ entrypoints: backend, contributions: [{ type: "mcp", id: "x.mcp", external_tools: true }] }))).toBe(true);
  });

  it("reads the store listing flag", () => {
    expect(marketplacePluginProvidesMcpTools({ mcpTools: true })).toBe(true);
    expect(marketplacePluginProvidesMcpTools({})).toBe(false);
  });
});