mirror of
https://github.com/lawrencehook/remove-youtube-suggestions.git
synced 2026-07-25 06:54:31 +00:00
84b103e46b
Replace file-per-record auth requests, file-per-hash rate limits, and JSON blob subscription cache with a single SQLite database via better-sqlite3. Consolidate duplicated email/IP rate limit code into shared helpers. Add missing IP rate limit pruning to cleanup interval. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
const fs = require('fs');
|
|
|
|
// Set up test environment variables
|
|
process.env.JWT_SECRET = 'test-secret-key-for-testing-only-32chars';
|
|
process.env.STRIPE_SECRET_KEY = 'sk_test_fake';
|
|
process.env.STRIPE_PRICE_MONTHLY = 'price_test_monthly';
|
|
process.env.STRIPE_PRICE_YEARLY = 'price_test_yearly';
|
|
process.env.STRIPE_WEBHOOK_SECRET = 'whsec_test';
|
|
process.env.EMAIL_FROM = 'test@example.com';
|
|
process.env.BASE_URL = 'http://localhost:3000';
|
|
process.env.DATA_DIR = './tests/test-data';
|
|
|
|
// Clean up test data directory
|
|
const testDataDir = './tests/test-data';
|
|
|
|
function cleanTestData() {
|
|
const storage = require('../src/storage');
|
|
storage.closeDatabase();
|
|
try {
|
|
if (fs.existsSync(testDataDir)) {
|
|
fs.rmSync(testDataDir, { recursive: true, force: true });
|
|
}
|
|
} catch (err) {
|
|
// Ignore ENOTEMPTY errors from race conditions in parallel tests
|
|
if (err.code !== 'ENOTEMPTY' && err.code !== 'ENOENT') {
|
|
throw err;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Clean before tests
|
|
cleanTestData();
|
|
|
|
// Export for use in tests
|
|
module.exports = {
|
|
cleanTestData,
|
|
testDataDir,
|
|
};
|