Merge pull request #5 from yardstick/logger-test

new log stuff
This commit is contained in:
brmnjsh 2019-03-15 01:06:54 -04:00 committed by GitHub
commit e898a50cf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

40
src/test/logger.spec.ts Normal file
View File

@ -0,0 +1,40 @@
var expect = require('chai').expect;
var logger = require('../logger');
describe('Logger', function () {
it('should get correct last logged item in error log', function () {
var options = {
limit: 1,
start: 0,
order: 'desc',
fields: ['message']
};
var errorTest = `error log test`;
logger.errorLog.info(errorTest);
logger.errorLog.query(options, function (err: any, result: any) {
if (err) {
throw err;
}
expect(result.file[0].message).to.be.equal(errorTest);
});
});
it('should get correct last logged item in access log', function () {
var options = {
limit: 1,
start: 0,
order: 'desc',
fields: ['message']
};
var accessTest = `access log test`;
logger.accessLog.info(accessTest);
logger.accessLog.query(options, function (err: any, result: any) {
if (err) {
throw err;
}
expect(result.file[0].message).to.be.equal(accessTest);
});
});
});