mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-11 01:52:55 +01:00
test: dont clear local when testing
This commit is contained in:
@@ -28,8 +28,11 @@ const total = _.cloneDeep(local);
|
|||||||
|
|
||||||
const runJobs = nconf.get('runJobs');
|
const runJobs = nconf.get('runJobs');
|
||||||
|
|
||||||
|
Analytics.pause = false;
|
||||||
|
|
||||||
Analytics.init = async function () {
|
Analytics.init = async function () {
|
||||||
new cronJob('*/10 * * * * *', (async () => {
|
new cronJob('*/10 * * * * *', (async () => {
|
||||||
|
if (Analytics.pause) return;
|
||||||
publishLocalAnalytics();
|
publishLocalAnalytics();
|
||||||
if (runJobs) {
|
if (runJobs) {
|
||||||
await sleep(2000);
|
await sleep(2000);
|
||||||
|
|||||||
@@ -126,9 +126,9 @@ describe('Analytics', () => {
|
|||||||
|
|
||||||
it('should increment various metrics', async () => {
|
it('should increment various metrics', async () => {
|
||||||
let counters;
|
let counters;
|
||||||
|
analytics.pause = true;
|
||||||
({ counters } = analytics.peek());
|
({ counters } = analytics.peek());
|
||||||
const before = { ...counters };
|
const before = { ...counters };
|
||||||
const { setTimeout } = require('timers/promises');
|
|
||||||
const id = `https://example.org/activity/${utils.generateUUID()}`;
|
const id = `https://example.org/activity/${utils.generateUUID()}`;
|
||||||
await controllers.activitypub.postInbox({
|
await controllers.activitypub.postInbox({
|
||||||
body: {
|
body: {
|
||||||
@@ -141,7 +141,7 @@ describe('Analytics', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, { sendStatus: () => {} });
|
}, { sendStatus: () => {} });
|
||||||
await setTimeout(2000);
|
|
||||||
({ counters } = analytics.peek());
|
({ counters } = analytics.peek());
|
||||||
const after = { ...counters };
|
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], JSON.stringify({ before, after }, null, 2));
|
||||||
assert(before[metric] < after[metric]);
|
assert(before[metric] < after[metric]);
|
||||||
});
|
});
|
||||||
|
analytics.pause = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user