api-server/test/mocks/bullmq.mock.ts
WangDL 5fd737967f
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 23s
feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log

M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger

M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint

M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation

E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00

63 lines
1.6 KiB
TypeScript

import { Injectable, Inject, Module } from '@nestjs/common'
@Injectable()
class FakeQueue {
getWaitingCount = () => 0
getActiveCount = () => 0
getCompletedCount = () => 0
getFailedCount = () => Promise.resolve([])
getDelayedCount = () => 0
getFailed = () => Promise.resolve([])
getJob = () => Promise.resolve(null)
add = () => Promise.resolve({ id: 'fake-job' })
close = () => Promise.resolve()
}
@Injectable()
class FakeFlowProducer {
add = () => Promise.resolve({ jobId: 'fake-flow' })
close = () => Promise.resolve()
}
@Module({})
export class BullModule {
static forRootAsync(_opts?: any): any {
return { module: BullModule }
}
static registerQueue(...names: { name: string }[]): any {
const providers = names.map((n) => ({
provide: `BullQueue_${n.name}`,
useClass: FakeQueue,
}))
return { module: BullModule, providers, exports: providers }
}
static registerFlowProducer(opts: { name: string }): any {
const providers = [
{ provide: `BullFlowProducer_${opts.name}`, useClass: FakeFlowProducer },
]
return { module: BullModule, providers, exports: providers }
}
}
export const InjectQueue = (name: string): ParameterDecorator =>
Inject(`BullQueue_${name}`)
export const InjectFlowProducer = (name: string): ParameterDecorator =>
Inject(`BullFlowProducer_${name}`)
export function Processor(_name: string): ClassDecorator {
return (target: any) => {
Injectable()(target)
}
}
export class WorkerHost {
worker: any = { on: () => {}, close: () => Promise.resolve() }
}
export const OnWorkerEvent = (_event: string): MethodDecorator => {
return () => {}
}