forked from mtusi2026/mtusi2026lab3
lab3: итог
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { IdempotencyRepository } from './idempotency.repository.js';
|
||||
|
||||
describe('IdempotencyRepository expired-key cleanup', () => {
|
||||
it('deletes only rows older than the configured TTL', async () => {
|
||||
const query = vi.fn().mockResolvedValue({ rowCount: 0, rows: [] });
|
||||
const repository = new IdempotencyRepository({ query } as never);
|
||||
|
||||
await repository.forget('user', '/api/v1/chats/chat/messages', 'key', 86400);
|
||||
|
||||
expect(query).toHaveBeenCalledWith(
|
||||
'idempotency.forget',
|
||||
expect.stringContaining(
|
||||
'created_at < now() - make_interval(secs => $4::double precision)',
|
||||
),
|
||||
['user', '/api/v1/chats/chat/messages', 'key', 86400],
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user