Merge branch 'refactor-tap' into ci/update-ci

This commit is contained in:
Lam Wei Li 2022-07-25 22:43:14 +08:00
commit 20ca0e54ad
No known key found for this signature in database
GPG Key ID: 90F6ABECF080D7BF
9 changed files with 65 additions and 16 deletions

View File

@ -8,12 +8,18 @@ let log4js;
let recording;
test('log4js appender dependencies', (batch) => {
batch.beforeEach(() => {
batch.beforeEach((done) => {
log4js = require('../../lib/log4js');
recording = require('../../lib/appenders/recording');
if (typeof done === 'function') {
done();
}
});
batch.afterEach(() => {
batch.afterEach((done) => {
recording.erase();
if (typeof done === 'function') {
done();
}
});
batch.test('in order', (t) => {
const config = {

View File

@ -3,8 +3,11 @@ const log4js = require('../../lib/log4js');
const recording = require('../../lib/appenders/recording');
test('log4js categoryFilter', (batch) => {
batch.beforeEach(() => {
batch.beforeEach((done) => {
recording.reset();
if (typeof done === 'function') {
done();
}
});
batch.test('appender should exclude categories', (t) => {

View File

@ -10,7 +10,7 @@ let dependencies;
let fileRead;
test('log4js configure', (batch) => {
batch.beforeEach(() => {
batch.beforeEach((done) => {
fileRead = 0;
fakeFS = {
@ -55,6 +55,10 @@ test('log4js configure', (batch) => {
fs: fakeFS,
},
};
if (typeof done === 'function') {
done();
}
});
batch.test(

View File

@ -68,8 +68,11 @@ test('log4js connect logger', (batch) => {
const ml = new MockLogger();
const cl = clm(ml, { context: true });
t.beforeEach(() => {
t.beforeEach((done) => {
ml.contexts = [];
if (typeof done === 'function') {
done();
}
});
t.test('response should be included in context', (assert) => {
@ -96,8 +99,11 @@ test('log4js connect logger', (batch) => {
const ml = new MockLogger();
const cl = clm(ml, {});
t.beforeEach(() => {
t.beforeEach((done) => {
ml.contexts = [];
if (typeof done === 'function') {
done();
}
});
t.test('response should not be included in context', (assert) => {

View File

@ -59,8 +59,11 @@ test('log4js connect logger', (batch) => {
const ml = new MockLogger();
const cl = clm(ml, { nolog: '\\.gif' });
t.beforeEach(() => {
t.beforeEach((done) => {
ml.messages = [];
if (typeof done === 'function') {
done();
}
});
t.test('check unmatch url request', (assert) => {
@ -106,8 +109,11 @@ test('log4js connect logger', (batch) => {
const ml = new MockLogger();
const cl = clm(ml, { nolog: '\\.gif|\\.jpe?g' });
t.beforeEach(() => {
t.beforeEach((done) => {
ml.messages = [];
if (typeof done === 'function') {
done();
}
});
t.test('check unmatch url request (png)', (assert) => {
@ -167,8 +173,11 @@ test('log4js connect logger', (batch) => {
const ml = new MockLogger();
const cl = clm(ml, { nolog: ['\\.gif', '\\.jpe?g'] });
t.beforeEach(() => {
t.beforeEach((done) => {
ml.messages = [];
if (typeof done === 'function') {
done();
}
});
t.test('check unmatch url request (png)', (assert) => {
@ -228,8 +237,11 @@ test('log4js connect logger', (batch) => {
const ml = new MockLogger();
const cl = clm(ml, { nolog: /\.gif|\.jpe?g/ });
t.beforeEach(() => {
t.beforeEach((done) => {
ml.messages = [];
if (typeof done === 'function') {
done();
}
});
t.test('check unmatch url request (png)', (assert) => {
@ -289,8 +301,11 @@ test('log4js connect logger', (batch) => {
const ml = new MockLogger();
const cl = clm(ml, { nolog: [/\.gif/, /\.jpe?g/] });
t.beforeEach(() => {
t.beforeEach((done) => {
ml.messages = [];
if (typeof done === 'function') {
done();
}
});
t.test('check unmatch url request (png)', (assert) => {
@ -353,8 +368,11 @@ test('log4js connect logger', (batch) => {
res.getHeader('content-type') === 'image/png' || res.statusCode < 400,
});
t.beforeEach(() => {
t.beforeEach((done) => {
ml.messages = [];
if (typeof done === 'function') {
done();
}
});
t.test('check unmatch function return (statusCode < 400)', (assert) => {

View File

@ -35,9 +35,12 @@ const testConfig = {
};
test('../../lib/logger', (batch) => {
batch.beforeEach(() => {
batch.beforeEach((done) => {
events.length = 0;
testConfig.level = levels.TRACE;
if (typeof done === 'function') {
done();
}
});
batch.test('constructor with no parameters', (t) => {

View File

@ -51,8 +51,11 @@ function makeFakeNet() {
}
test('Multiprocess Appender', async (batch) => {
batch.beforeEach(() => {
batch.beforeEach((done) => {
recording.erase();
if (typeof done === 'function') {
done();
}
});
batch.test('worker', (t) => {

View File

@ -3,8 +3,11 @@ const log4js = require('../../lib/log4js');
const recording = require('../../lib/appenders/recording');
test('../../lib/logger', (batch) => {
batch.beforeEach(() => {
batch.beforeEach((done) => {
recording.reset();
if (typeof done === 'function') {
done();
}
});
batch.test('creating a new log level', (t) => {

View File

@ -6,8 +6,11 @@ const recording = require('../../lib/appenders/recording');
* test a simple regexp
*/
test('log4js noLogFilter', (batch) => {
batch.beforeEach(() => {
batch.beforeEach((done) => {
recording.reset();
if (typeof done === 'function') {
done();
}
});
batch.test(