完善平台、基准模型、定价规则和实时负载的紧凑查询与滚动展示,并固定关键操作列。 新增管理员任务记录、批量计费结算和用户组限流、额度及模型权限维护能力,同时补充任务脱敏、查询索引与 OpenAPI 契约。 验证:pnpm openapi、Go 全量测试、pnpm lint、pnpm test、pnpm build、gofmt 与差异格式检查均通过。
27 lines
937 B
TypeScript
27 lines
937 B
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import { retrySettlementBatch } from './BillingSettlementsPanel';
|
|
|
|
describe('billing settlement batch processing', () => {
|
|
it('continues after individual failures and reports failed settlement IDs', async () => {
|
|
const active = new Set<string>();
|
|
let peakConcurrency = 0;
|
|
const retryOne = vi.fn(async (item: { id: string }) => {
|
|
active.add(item.id);
|
|
peakConcurrency = Math.max(peakConcurrency, active.size);
|
|
await Promise.resolve();
|
|
active.delete(item.id);
|
|
if (item.id === 'failed') throw new Error('retry failed');
|
|
});
|
|
|
|
const result = await retrySettlementBatch(
|
|
[{ id: 'first' }, { id: 'failed' }, { id: 'last' }],
|
|
retryOne,
|
|
2,
|
|
);
|
|
|
|
expect(result).toEqual({ failedIds: ['failed'], succeeded: 2 });
|
|
expect(retryOne).toHaveBeenCalledTimes(3);
|
|
expect(peakConcurrency).toBeLessThanOrEqual(2);
|
|
});
|
|
});
|