test: clear cache between runs, require middleware later in helpers

This commit is contained in:
Barış Soner Uşaklı
2021-04-18 21:38:47 -04:00
committed by Andrew Rodrigues
parent d15e27107e
commit 2ea468daa3
7 changed files with 28 additions and 22 deletions

View File

@@ -176,6 +176,7 @@ async function setupMockDefaults() {
require('../../src/groups').cache.reset();
require('../../src/posts/cache').reset();
require('../../src/cache').reset();
require('../../src/middleware/uploads').clearCache();
winston.info('test_database flushed');
await setupDefaultConfigs(meta);
@@ -185,6 +186,7 @@ async function setupMockDefaults() {
meta.config.initialPostDelay = 0;
meta.config.newbiePostDelay = 0;
meta.config.autoDetectLang = 0;
// meta.config.uploadRateLimitCooldown = 1;
await enableDefaultPlugins();

View File

@@ -79,7 +79,7 @@ describe('Upload Controllers', () => {
it('should fail if the user exceeds the upload rate limit threshold', (done) => {
const oldValue = meta.config.allowedFileExtensions;
meta.config.allowedFileExtensions = 'png,jpg,bmp,html';
require('../src/middleware/uploads').clearCache();
// why / 2? see: helpers.uploadFile for a weird quirk where we actually upload 2 files per upload in our tests.
console.log('times', (meta.config.uploadRateLimitThreshold / 2) + 1);
const times = (meta.config.uploadRateLimitThreshold / 2) + 1;