Skip to content

Commit

Permalink
test: mv assert to fixtures (eggjs#3829)
Browse files Browse the repository at this point in the history
  • Loading branch information
thonatos authored and atian25 committed Jul 22, 2019
1 parent 79dbb14 commit 341beda
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
18 changes: 17 additions & 1 deletion test/fixtures/apps/dumpconfig/app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
const fs = require('fs');
const path = require('path');
const assert = require('assert');
const sleep = require('mz-modules/sleep');

function readJSON(p) {
return JSON.parse(fs.readFileSync(p));
}

module.exports = app => {
const baseDir = app.config.baseDir;
let json;

app.config.dynamic = 1;
app.beforeStart(function*() {
yield sleep(500);
// dumpConfig() dynamically
json = readJSON(path.join(baseDir, 'run/application_config.json'));
assert(json.config.dynamic === 1, 'should dump in config');
json = readJSON(path.join(baseDir, 'run/agent_config.json'));
assert(json.config.dynamic === 0, 'should dump in config');

yield sleep(2000);
app.config.dynamic = 2;
});
};
7 changes: 0 additions & 7 deletions test/lib/egg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,8 @@ describe('test/lib/egg.test.js', () => {
const baseDir = utils.getFilepath('apps/dumpconfig');
let json;

await sleep(100);
json = readJson(path.join(baseDir, 'run/application_config.json'));
assert(json.config.dynamic === 1);
json = readJson(path.join(baseDir, 'run/agent_config.json'));
assert(json.config.dynamic === 0);

await app.ready();

await sleep(100);
json = readJson(path.join(baseDir, 'run/application_config.json'));
assert(json.config.dynamic === 2);
json = readJson(path.join(baseDir, 'run/agent_config.json'));
Expand Down

0 comments on commit 341beda

Please sign in to comment.