Skip to content

Commit

Permalink
test: test for closing logger (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
popomore authored and dead-horse committed Mar 28, 2017
1 parent 5f5cf91 commit 7ab3791
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"co": "^4.6.0",
"debug": "^2.6.3",
"delegates": "^1.0.0",
"egg-cluster": "^1.6.1",
"egg-cluster": "^1.6.2",
"egg-cookies": "^2.2.1",
"egg-core": "^3.0.0",
"egg-development": "^1.2.0",
Expand All @@ -32,25 +32,25 @@
"egg-schedule": "^2.3.0",
"egg-security": "^1.8.0",
"egg-session": "^2.1.0",
"egg-static": "^1.2.0",
"egg-static": "^1.3.0",
"egg-view": "^1.0.1",
"egg-watcher": "^2.1.0",
"extend": "^3.0.0",
"graceful": "^1.0.1",
"is-type-of": "^1.0.0",
"koa-bodyparser": "^2.4.0",
"koa-bodyparser": "^2.5.0",
"koa-is-json": "^1.0.0",
"mime-types": "^2.1.14",
"mime-types": "^2.1.15",
"sendmessage": "^1.1.0",
"urllib": "^2.21.2",
"utility": "^1.11.0"
},
"devDependencies": {
"autod": "^2.7.1",
"autod": "^2.8.0",
"autod-egg": "^1.0.0",
"coffee": "^3.3.0",
"egg-alinode": "^1.0.3",
"egg-bin": "^3.0.1",
"egg-bin": "^3.1.0",
"egg-mock": "^3.2.0",
"egg-plugin-puml": "^1.0.0",
"egg-view-nunjucks": "^2.0.0",
Expand All @@ -70,6 +70,7 @@
"rimraf": "^2.6.1",
"runscript": "^1.2.1",
"should": "^11.2.1",
"spy": "^1.0.0",
"supertest": "^3.0.0",
"taffydb": "^2.7.3",
"webstorm-disable-index": "^1.1.2"
Expand Down
17 changes: 17 additions & 0 deletions test/lib/egg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const path = require('path');
const fs = require('fs');
const request = require('supertest');
const sleep = require('mz-modules/sleep');
const spy = require('spy');
const Transport = require('egg-logger').Transport;
const utils = require('../utils');

describe('test/lib/egg.test.js', () => {
Expand Down Expand Up @@ -130,6 +132,21 @@ describe('test/lib/egg.test.js', () => {
assert(isAppClosed === true);
assert(isAgentClosed === true);
});

it('shoud close logger', function* () {
const close = spy();
class TestTransport extends Transport {
close() {
close();
}
}
const transport = new TestTransport();
for (const logger of app.loggers.values()) {
logger.set('test', transport);
}
yield app.close();
assert(close.called);
});
});

describe('handle unhandledRejection', () => {
Expand Down

0 comments on commit 7ab3791

Please sign in to comment.