fix: test

This commit is contained in:
archer
2025-12-09 18:17:31 +08:00
parent 7dc7e29715
commit 111bfc6a0d
2 changed files with 6 additions and 6 deletions

View File

@@ -23,7 +23,7 @@ TrackSchema.index(
);
// QPM index
TrackSchema.index(
{ event: 1, createTime: -1 },
{ event: 1, createTime: -1, 'data.requestCount': 1 },
{
partialFilterExpression: {
event: TrackEnum.teamChatQPM

View File

@@ -121,27 +121,27 @@ describe('VectorDB Controller', () => {
const result = await getVectorCountByTeamId('team_123');
expect(result).toBe(150);
expect(mockGetVectorCountByTeamId).not.toHaveBeenCalled();
expect(mockGetVectorCount).not.toHaveBeenCalled();
});
it('should fetch from Vector and cache if no cache exists', async () => {
mockGetRedisCache.mockResolvedValue(null);
mockGetVectorCountByTeamId.mockResolvedValue(200);
mockGetVectorCount.mockResolvedValue(200);
const result = await getVectorCountByTeamId('team_456');
expect(result).toBe(200);
expect(mockGetVectorCountByTeamId).toHaveBeenCalledWith('team_456');
expect(mockGetVectorCount).toHaveBeenCalledWith({ teamId: 'team_456' });
});
it('should handle undefined cache value', async () => {
mockGetRedisCache.mockResolvedValue(undefined);
mockGetVectorCountByTeamId.mockResolvedValue(50);
mockGetVectorCount.mockResolvedValue(50);
const result = await getVectorCountByTeamId('team_789');
expect(result).toBe(50);
expect(mockGetVectorCountByTeamId).toHaveBeenCalled();
expect(mockGetVectorCount).toHaveBeenCalledWith({ teamId: 'team_789' });
});
});