mirror of
https://github.com/upstash/context7.git
synced 2026-09-14 19:09:34 +08:00
4e980f6b49
* fix(mcp): increase HTTP subscription capacity * fix(mcp): use benchmarked subscription capacity * fix(mcp): set subscription ceiling to 24k * fix(mcp): start subscription ceiling at 16k * fix(mcp): clarify subscription limit safeguards
27 lines
819 B
TypeScript
27 lines
819 B
TypeScript
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
import { DEFAULT_MAX_SUBSCRIPTIONS, getMaxSubscriptions } from "../src/lib/subscriptions.js";
|
|
|
|
describe("getMaxSubscriptions", () => {
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
test("defaults to 16000 subscriptions", () => {
|
|
expect(getMaxSubscriptions(undefined)).toBe(DEFAULT_MAX_SUBSCRIPTIONS);
|
|
});
|
|
|
|
test("accepts a positive integer override", () => {
|
|
expect(getMaxSubscriptions("8192")).toBe(8_192);
|
|
});
|
|
|
|
test.each(["0", "-1", "1.5", "invalid", "Infinity"])(
|
|
"falls back for invalid value %s",
|
|
(value) => {
|
|
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
|
|
expect(getMaxSubscriptions(value)).toBe(DEFAULT_MAX_SUBSCRIPTIONS);
|
|
expect(warn).toHaveBeenCalledOnce();
|
|
}
|
|
);
|
|
});
|