Files
Claude 9a4853a484
Deploy FileDrop / deploy (push) Successful in 48s
fix: remove UploadBatcher crash window, make bot concurrency configurable, fix all test import paths
- Removed UploadBatcher (src/infrastructure/telegram/upload-batcher.ts + DI):
  pending uploads no longer lost on crash, files sent directly to Telegram
- Changed upload-controller to use Bun.file().stream() instead of createReadStream
- Made PER_BOT_CONCURRENCY configurable via TELEGRAM_BOT_CONCURRENCY env
- Fixed 18 test files with updated import paths and mock shapes
- Updated package.json test script: telegramQueue.test.ts → bot-pool.test.ts
- Build, lint, and test suite all pass
2026-07-29 17:06:35 +07:00

36 lines
982 B
TypeScript

import { beforeEach, describe, expect, it } from 'bun:test';
import { config } from '../src/env';
import {
checkRateLimit,
cleanupRateLimitCache,
clearRateLimitCache,
} from '../src/interfaces/http/middleware/rate-limit';
describe('Rate Limiter', () => {
beforeEach(() => {
clearRateLimitCache();
});
it('should allow requests up to the configured limit then block', () => {
const key = 'user-1';
const limit = config.rateLimitMaxRequests;
for (let i = 0; i < limit; i++) {
expect(checkRateLimit(key)).toBe(true);
}
expect(checkRateLimit(key)).toBe(false);
});
it('should track different IPs independently', () => {
expect(checkRateLimit('10.0.0.1')).toBe(true);
expect(checkRateLimit('10.0.0.1')).toBe(true);
expect(checkRateLimit('10.0.0.2')).toBe(true);
});
it('should no-op on cleanup of active entries', () => {
checkRateLimit('user-3');
expect(() => cleanupRateLimitCache()).not.toThrow();
});
});