Files
lindyson-ai/apps/api/tests/promptWizardQueue.test.ts
Juno ChowandClaude Fable 5.1 f665082dad chore: 建立产品仓库,完成开源前的敏感信息清理
前端(Vite + React)、API/worker(Fastify + BullMQ)、api-contracts 契约包、
迁移脚本、测试与自托管 docker-compose 示例。

开源准备:运维脚本与机器信息已拆到私有仓库;公司名、备案号、隐私邮箱改读
publicCompliance.local.json(仓库只保留占位模板);站点地址与客服二维码改为
VITE_ 环境变量;fixtures 中的真实用户标识已匿名化;三个 package.json 标注
Apache-2.0。

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-16 02:10:46 +08:00

41 lines
1.0 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from 'vitest';
const queueMock = vi.hoisted(() => ({
add: vi.fn().mockResolvedValue(undefined),
close: vi.fn().mockResolvedValue(undefined),
on: vi.fn(),
setGlobalConcurrency: vi.fn().mockResolvedValue(undefined),
}));
vi.mock('../src/config/env.js', () => ({
env: {
REDIS_URL: 'redis://localhost:6379',
PROMPT_WIZARD_QUEUE_CONCURRENCY: 10,
},
}));
vi.mock('bullmq', () => ({
Queue: vi.fn(function Queue() {
return queueMock;
}),
}));
import {
closePromptWizardQueue,
configurePromptWizardQueueGlobalConcurrency,
} from '../src/queues/promptWizardQueue.js';
afterEach(async () => {
await closePromptWizardQueue();
vi.clearAllMocks();
});
describe('提示词向导 BullMQ 全局并发', () => {
it('默认把所有 worker 共享的全局并发上限设置为 10', async () => {
await configurePromptWizardQueueGlobalConcurrency();
expect(queueMock.setGlobalConcurrency).toHaveBeenCalledOnce();
expect(queueMock.setGlobalConcurrency).toHaveBeenCalledWith(10);
});
});