Перенесено дерево lab5 целиком: NestJS-приложение (API + worker,
RabbitMQ, outbox, S3), Dockerfile, compose.yaml, infra/{haproxy,minio,
rabbitmq}, стендовые скрипты, scripts/lab4, scripts/lab5,
evidence/lab4, evidence/lab5 и contracts/extensions.openapi.json.
Задание lab6 оставлено своим: README, REPORT, COURSE, lab.json,
contracts/{openapi,infrastructure,jobs.schema,attachment-states,
examples,observability}, tests, compose.example.yaml, infra/otel,
.github/pull_request_template.md.
Адаптации при переносе:
- docker-проект mtusi-lab5 -> mtusi-lab6 и тег образа
mtusi-messenger:lab6 (compose.yaml, scripts/stop-one.sh, .env.example,
infra/README.md), чтобы тома и контейнеры не пересекались с lab5;
- Makefile: цели lab5 сохранены целиком (skeleton lab6 не отличается
от skeleton lab5);
- .env.example: переменные приложения и стенда lab5 + блок lab6
(OTEL_*) из skeleton.
25 lines
730 B
TypeScript
25 lines
730 B
TypeScript
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],
|
|
);
|
|
});
|
|
});
|