From 20d3cea8d17e6102d6817f1b5dd8533f09da453c Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Mon, 6 May 2019 08:34:14 +1000 Subject: [PATCH] test: new version of sandboxed-module to fix tests in v12 --- CHANGELOG.md | 1 + package-lock.json | 6 +- package.json | 2 +- test/tap/configuration-validation-test.js | 100 +++++----------------- 4 files changed, 25 insertions(+), 84 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd81cf7..b2d68c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # log4js-node changelog ## 4.1.1 +* [Fix layout problem in node v12](https://github.com/log4js-node/log4js-node/pull/860) - thanks [@bjornstar](https://github.com/bjornstar) * [Add missing types for addLevels](https://github.com/log4js-node/log4js-node/pull/867) - thanks [@Ivkaa](https://github.com/Ivkaa) * [Allow any return type for layout function](https://github.com/log4js-node/log4js-node/pull/845) - thanks [@xinbenlv](https://github.com/xinbenlv) diff --git a/package-lock.json b/package-lock.json index 24df0af..2fa3570 100644 --- a/package-lock.json +++ b/package-lock.json @@ -120,9 +120,9 @@ } }, "@log4js-node/sandboxed-module": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@log4js-node/sandboxed-module/-/sandboxed-module-2.2.0.tgz", - "integrity": "sha1-LqUDoR57R36DvNWPd3hba02PmGo=", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@log4js-node/sandboxed-module/-/sandboxed-module-2.2.1.tgz", + "integrity": "sha512-BtpxW7EReVwZ6WSNHPMyID2vVYuBKYkJyevJxbPsTtecWGqwm1wL4/O3oOQcyGhJsuNi7Y8JhNc5FE9jdXlZ0A==", "dev": true, "requires": { "require-like": "0.1.2", diff --git a/package.json b/package.json index 34c5f1a..3df9d1f 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "streamroller": "^1.0.4" }, "devDependencies": { - "@log4js-node/sandboxed-module": "^2.2.0", + "@log4js-node/sandboxed-module": "^2.2.1", "codecov": "^3.3.0", "conventional-changelog": "^3.1.4", "deep-freeze": "0.0.1", diff --git a/test/tap/configuration-validation-test.js b/test/tap/configuration-validation-test.js index 39c7789..53a3509 100644 --- a/test/tap/configuration-validation-test.js +++ b/test/tap/configuration-validation-test.js @@ -38,191 +38,131 @@ test('log4js configuration validation', (batch) => { }); batch.test('should give error if config is an empty object', (t) => { - const expectedError = new Error( - 'Problem with log4js configuration: ({}) - must have a property "appenders" of type object.' + t.throws( + () => log4js.configure({}), + /- must have a property "appenders" of type object\./ ); - t.throws(() => log4js.configure({}), expectedError); t.end(); }); batch.test('should give error if config has no appenders', (t) => { - const expectedError = new Error( - 'Problem with log4js configuration: ({ categories: {} }) ' - + '- must have a property "appenders" of type object.' + t.throws( + () => log4js.configure({ categories: {} }), + /- must have a property "appenders" of type object\./ ); - t.throws(() => log4js.configure({ categories: {} }), expectedError); t.end(); }); batch.test('should give error if config has no categories', (t) => { - const expectedError = new Error( - 'Problem with log4js configuration: ({ appenders: { out: { type: \'stdout\' } } }) ' - + '- must have a property "categories" of type object.' + t.throws( + () => log4js.configure({ appenders: { out: { type: 'stdout' } } }), + /- must have a property "categories" of type object\./ ); - t.throws(() => log4js.configure({ appenders: { out: { type: 'stdout' } } }), expectedError); t.end(); }); batch.test('should give error if appenders is not an object', (t) => { - const error = new Error( - 'Problem with log4js configuration: ({ appenders: [], categories: [] })' - + ' - must have a property "appenders" of type object.' - ); t.throws( () => log4js.configure({ appenders: [], categories: [] }), - error + /- must have a property "appenders" of type object\./ ); t.end(); }); batch.test('should give error if appenders are not all valid', (t) => { - const error = new Error( - 'Problem with log4js configuration: ({ appenders: { thing: \'cheese\' }, categories: {} })' - + ' - appender "thing" is not valid (must be an object with property "type")' - ); t.throws( () => log4js.configure({ appenders: { thing: 'cheese' }, categories: {} }), - error + /- appender "thing" is not valid \(must be an object with property "type"\)/ ); t.end(); }); batch.test('should require at least one appender', (t) => { - const error = new Error( - 'Problem with log4js configuration: ({ appenders: {}, categories: {} })' - + ' - must define at least one appender.' - ); t.throws( () => log4js.configure({ appenders: {}, categories: {} }), - error + /- must define at least one appender\./ ); t.end(); }); batch.test('should give error if categories are not all valid', (t) => { - const error = new Error( - 'Problem with log4js configuration: ' - + '({ appenders: { stdout: { type: \'stdout\' } },\n categories: { thing: \'cheese\' } })' - + ' - category "thing" is not valid (must be an object with properties "appenders" and "level")' - ); t.throws( () => log4js.configure({ appenders: { stdout: { type: 'stdout' } }, categories: { thing: 'cheese' } }), - error + /- category "thing" is not valid \(must be an object with properties "appenders" and "level"\)/ ); t.end(); }); batch.test('should give error if default category not defined', (t) => { - const error = new Error( - 'Problem with log4js configuration: ' - + '({ appenders: { stdout: { type: \'stdout\' } },\n' - + ' categories: { thing: { appenders: [ \'stdout\' ], level: \'ERROR\' } } })' - + ' - must define a "default" category.' - ); t.throws( () => log4js.configure({ appenders: { stdout: { type: 'stdout' } }, categories: { thing: { appenders: ['stdout'], level: 'ERROR' } } }), - error + /- must define a "default" category\./ ); t.end(); }); batch.test('should require at least one category', (t) => { - const error = new Error( - 'Problem with log4js configuration: ({ appenders: { stdout: { type: \'stdout\' } }, categories: {} })' - + ' - must define at least one category.' - ); t.throws( () => log4js.configure({ appenders: { stdout: { type: 'stdout' } }, categories: {} }), - error + /- must define at least one category\./ ); t.end(); }); batch.test('should give error if category.appenders is not an array', (t) => { - const error = new Error( - 'Problem with log4js configuration: ' - + '({ appenders: { stdout: { type: \'stdout\' } },\n' - + ' categories: { thing: { appenders: {}, level: \'ERROR\' } } })' - + ' - category "thing" is not valid (appenders must be an array of appender names)' - ); t.throws( () => log4js.configure({ appenders: { stdout: { type: 'stdout' } }, categories: { thing: { appenders: {}, level: 'ERROR' } } }), - error + /- category "thing" is not valid \(appenders must be an array of appender names\)/ ); t.end(); }); batch.test('should give error if category.appenders is empty', (t) => { - const error = new Error( - 'Problem with log4js configuration: ' - + '({ appenders: { stdout: { type: \'stdout\' } },\n' - + ' categories: { thing: { appenders: [], level: \'ERROR\' } } })' - + ' - category "thing" is not valid (appenders must contain at least one appender name)' - ); t.throws( () => log4js.configure({ appenders: { stdout: { type: 'stdout' } }, categories: { thing: { appenders: [], level: 'ERROR' } } }), - error + /- category "thing" is not valid \(appenders must contain at least one appender name\)/ ); t.end(); }); batch.test('should give error if categories do not refer to valid appenders', (t) => { - const error = new Error( - 'Problem with log4js configuration: ' - + '({ appenders: { stdout: { type: \'stdout\' } },\n' - + ' categories: { thing: { appenders: [ \'cheese\' ], level: \'ERROR\' } } })' - + ' - category "thing" is not valid (appender "cheese" is not defined)' - ); t.throws( () => log4js.configure({ appenders: { stdout: { type: 'stdout' } }, categories: { thing: { appenders: ['cheese'], level: 'ERROR' } } }), - error + /- category "thing" is not valid \(appender "cheese" is not defined\)/ ); t.end(); }); batch.test('should give error if category level is not valid', (t) => { - const error = new Error( - 'Problem with log4js configuration: ' - + '({ appenders: { stdout: { type: \'stdout\' } },\n' - + ' categories: { default: { appenders: [ \'stdout\' ], level: \'Biscuits\' } } })' - + ' - category "default" is not valid (level "Biscuits" not recognised; ' - + 'valid levels are ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, MARK, OFF)' - ); t.throws( () => log4js.configure({ appenders: { stdout: { type: 'stdout' } }, categories: { default: { appenders: ['stdout'], level: 'Biscuits' } } }), - error + /- category "default" is not valid \(level "Biscuits" not recognised; valid levels are ALL, TRACE/ ); t.end(); }); batch.test('should give error if appender type cannot be found', (t) => { - const error = new Error( - 'Problem with log4js configuration: ' - + '({ appenders: { thing: { type: \'cheese\' } },\n' - + ' categories: { default: { appenders: [ \'thing\' ], level: \'ERROR\' } } })' - + ' - appender "thing" is not valid (type "cheese" could not be found)' - ); t.throws( () => log4js.configure({ appenders: { thing: { type: 'cheese' } }, categories: { default: { appenders: ['thing'], level: 'ERROR' } } }), - error + /- appender "thing" is not valid \(type "cheese" could not be found\)/ ); t.end(); });