mirror of
https://github.com/eggjs/egg.git
synced 2024-12-04 07:14:30 +00:00
29 lines
791 B
JavaScript
29 lines
791 B
JavaScript
'use strict';
|
|
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const utils = require('../../utils');
|
|
const sleep = require('mz-modules/sleep');
|
|
|
|
describe('test/lib/plugins/schedule.test.js', () => {
|
|
it('should schedule work', function* () {
|
|
const app = utils.cluster('apps/schedule', {
|
|
workers: 2,
|
|
});
|
|
yield app.ready();
|
|
yield sleep(5000);
|
|
yield app.close();
|
|
const log = getLogContent('schedule');
|
|
contains(log, 'cron').should.within(1, 2);
|
|
});
|
|
});
|
|
|
|
function getLogContent(name) {
|
|
const logPath = path.join(__dirname, '../../fixtures/apps', name, 'logs', name, `${name}-web.log`);
|
|
return fs.readFileSync(logPath, 'utf8');
|
|
}
|
|
|
|
function contains(content, match) {
|
|
return content.split('\n').filter(line => line.indexOf(match) >= 0).length;
|
|
}
|