diff --git a/@xen-orchestra/log/logger.test.js b/@xen-orchestra/log/logger.test.js index b72635dfe3a..a97911a98e5 100644 --- a/@xen-orchestra/log/logger.test.js +++ b/@xen-orchestra/log/logger.test.js @@ -12,7 +12,7 @@ describe('logger', () => { const logsTransportDebug = [] const transportDebug = message => { - logsTransportDefault.push(message) + logsTransportDebug.push(message) } const logsTransportFatal = [] @@ -29,12 +29,12 @@ describe('logger', () => { }, { level: 'debug', - transport: transportTest, + transport: transportDebug, }, ]) ) - logsTransportDefault.length = 0 + logsTransportDebug.length = 0 logsTransportFatal.length = 0 }) @@ -46,10 +46,10 @@ describe('logger', () => { time: new Date(), } logger.debug(expected1.message) - assert.equal(logsTransportDefault[0].message, expected1.message) - assert.equal(typeof logsTransportDefault[0].level, 'number', `level attribute should exist`) - assert.equal(typeof logsTransportDefault[0].namespace, 'string', `namespace attribute should exist`) - assert.equal(logsTransportDefault[0].time instanceof Date, true, 'time attribute should exist') + assert.equal(logsTransportDebug[0].message, expected1.message) + assert.equal(typeof logsTransportDebug[0].level, 'number', `level attribute should exist`) + assert.equal(typeof logsTransportDebug[0].namespace, 'string', `namespace attribute should exist`) + assert.equal(logsTransportDebug[0].time instanceof Date, true, 'time attribute should exist') }) it('should log test 1 and 2', () => { const expected1 = { @@ -66,8 +66,8 @@ describe('logger', () => { } logger.debug(expected1.message) logger.debug(expected2.message) - assert.equal(logsTransportDefault[0].message, expected1.message) - assert.equal(logsTransportDefault[1].message, expected2.message) + assert.equal(logsTransportDebug[0].message, expected1.message) + assert.equal(logsTransportDebug[1].message, expected2.message) }) it('should log tests for debug', () => { const expectedDebug = { @@ -78,8 +78,8 @@ describe('logger', () => { time: new Date(), } logger.debug(expectedDebug.message) - assert.deepEqual(logsTransportDefault[0].message, expectedDebug.message) - assert.deepEqual(logsTransportDefault[0].level, expectedDebug.level) + assert.deepEqual(logsTransportDebug[0].message, expectedDebug.message) + assert.deepEqual(logsTransportDebug[0].level, expectedDebug.level) }) it('should log tests for info', () => { const expectedInfo = { @@ -90,8 +90,8 @@ describe('logger', () => { time: new Date(), } logger.info(expectedInfo.message) - assert.deepEqual(logsTransportDefault[0].message, expectedInfo.message) - assert.deepEqual(logsTransportDefault[0].level, expectedInfo.level) + assert.deepEqual(logsTransportDebug[0].message, expectedInfo.message) + assert.deepEqual(logsTransportDebug[0].level, expectedInfo.level) }) it('should log tests for warn', () => { const expectedWarn = { @@ -102,8 +102,8 @@ describe('logger', () => { time: new Date(), } logger.warn(expectedWarn.message) - assert.deepEqual(logsTransportDefault[0].message, expectedWarn.message) - assert.deepEqual(logsTransportDefault[0].level, expectedWarn.level) + assert.deepEqual(logsTransportDebug[0].message, expectedWarn.message) + assert.deepEqual(logsTransportDebug[0].level, expectedWarn.level) }) it('should log tests for error', () => { const expectedError = { @@ -114,8 +114,8 @@ describe('logger', () => { time: new Date(), } logger.error(expectedError.message) - assert.deepEqual(logsTransportDefault[0].message, expectedError.message) - assert.deepEqual(logsTransportDefault[0].level, expectedError.level) + assert.deepEqual(logsTransportDebug[0].message, expectedError.message) + assert.deepEqual(logsTransportDebug[0].level, expectedError.level) assert.ok(logsTransportFatal.length === 0, 'fatal logs should be empty') }) it('should log tests for fatal', () => { @@ -139,7 +139,7 @@ describe('logger', () => { time: new Date(), } logger.debug(null) - assert.deepEqual(logsTransportDefault[0].data, expected1.data) + assert.deepEqual(logsTransportDebug[0].data, expected1.data) }) it('should log an error on undefined', () => { const expected1 = { @@ -150,13 +150,13 @@ describe('logger', () => { time: new Date(), } logger.debug(undefined) - assert.deepEqual(logsTransportDefault[0].data, expected1.data) + assert.deepEqual(logsTransportDebug[0].data, expected1.data) }) it('should not dedup logs', () => { configure( createCaptureTransport([ { - transport: transportTest, + transport: transportDebug, }, ]) ) @@ -164,14 +164,14 @@ describe('logger', () => { for (let i = 0; i < 3; i++) { logger.debug('this line should be logged 3 times') } - assert.equal(logsTransportDefault.length, 3) + assert.equal(logsTransportDebug.length, 3) }) it('should dedup logs', () => { configure( createCaptureTransport([ dedupe({ timeout: 50, // without a defined timeout, the test will wait for 10 minutes - transport: transportTest, + transport: transportDebug, }), ]) ) @@ -179,6 +179,6 @@ describe('logger', () => { for (let i = 0; i < 3; i++) { logger.debug('this line should be logged only once') } - assert.equal(logsTransportDefault.length, 1) + assert.equal(logsTransportDebug.length, 1) }) })