25 lines
989 B
TypeScript
25 lines
989 B
TypeScript
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import { createClientErrorThrottleStore } from "../src/modules/admin/client-error-throttle.factory.js";
|
|
import { PostgresClientErrorThrottleStore } from "../src/modules/admin/client-error-throttle.postgres.store.js";
|
|
import { MemoryClientErrorThrottleStore } from "../src/modules/admin/client-error-throttle.store.js";
|
|
|
|
const prisma = {} as never;
|
|
|
|
test("默认使用进程内存储", () => {
|
|
const store = createClientErrorThrottleStore(prisma, "memory");
|
|
assert.ok(store instanceof MemoryClientErrorThrottleStore);
|
|
});
|
|
|
|
test("多实例可切换为 Postgres 共享存储", () => {
|
|
const store = createClientErrorThrottleStore(prisma, "postgres");
|
|
assert.ok(store instanceof PostgresClientErrorThrottleStore);
|
|
});
|
|
|
|
test("未知存储模式在启动时快速失败", () => {
|
|
assert.throws(
|
|
() => createClientErrorThrottleStore(prisma, "redis"),
|
|
/Unsupported CLIENT_ERROR_THROTTLE_STORE/,
|
|
);
|
|
});
|