test: dont clear local when testing

This commit is contained in:
Barış Soner Uşaklı
2025-02-18 11:57:28 -05:00
parent f282407322
commit 669755d1e9
2 changed files with 6 additions and 2 deletions

View File

@@ -28,8 +28,11 @@ const total = _.cloneDeep(local);
const runJobs = nconf.get('runJobs');
Analytics.pause = false;
Analytics.init = async function () {
new cronJob('*/10 * * * * *', (async () => {
if (Analytics.pause) return;
publishLocalAnalytics();
if (runJobs) {
await sleep(2000);

View File

@@ -126,9 +126,9 @@ describe('Analytics', () => {
it('should increment various metrics', async () => {
let counters;
analytics.pause = true;
({ counters } = analytics.peek());
const before = { ...counters };
const { setTimeout } = require('timers/promises');
const id = `https://example.org/activity/${utils.generateUUID()}`;
await controllers.activitypub.postInbox({
body: {
@@ -141,7 +141,7 @@ describe('Analytics', () => {
},
},
}, { sendStatus: () => {} });
await setTimeout(2000);
({ counters } = analytics.peek());
const after = { ...counters };
@@ -150,5 +150,6 @@ describe('Analytics', () => {
assert(before[metric] && after[metric], JSON.stringify({ before, after }, null, 2));
assert(before[metric] < after[metric]);
});
analytics.pause = false;
});
});