egg/test/lib/plugins/logrotator.test.js
fengmk2 56d1deb17a feat: support background task on ctx (#119)
* feat: support background task on ctx

```js
ctx.runAtBackground(function* (ctx) {
  // async actions here
});
```

* fix: eslint style no-useless-escape

* chore: add license
2016-10-29 11:28:22 +08:00

26 lines
680 B
JavaScript

'use strict';
const path = require('path');
const glob = require('glob');
const utils = require('../../utils');
describe('test/lib/plugins/logrotator.test.js', () => {
let app;
before(() => {
app = utils.app('apps/logrotator-app');
return app.ready();
});
after(() => app.close());
it('should rotate log file default', function* () {
const file = require.resolve('egg-logrotator/app/schedule/rotate_by_file.js');
yield app.runSchedule(file);
const files = glob.sync(path.join(app.config.logger.dir, '*.log.*'));
files.length.should.above(0);
files.forEach(file => {
file.should.match(/\.log\.\d{4}-\d{2}-\d{2}$/);
});
});
});