From 8dade49cd4f6c8215bf17b8bba3061155deaae0c Mon Sep 17 00:00:00 2001 From: Leko Date: Sat, 2 Dec 2017 03:10:26 +0900 Subject: [PATCH 1/2] test: Add test case for missing branch - The case of id is string, flags is number - The case of flags is not 0 --- test/parallel/test-crypto-engine.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/parallel/test-crypto-engine.js b/test/parallel/test-crypto-engine.js index b731ec2f0372fa..99ab42174d1acc 100644 --- a/test/parallel/test-crypto-engine.js +++ b/test/parallel/test-crypto-engine.js @@ -5,6 +5,7 @@ if (!common.hasCrypto) common.skip('missing crypto'); const crypto = require('crypto'); +const notExistsEngineName = 'xxx'; common.expectsError( () => crypto.setEngine(true), @@ -21,3 +22,20 @@ common.expectsError( type: TypeError, message: 'The "flags" argument must be of type number' }); + +common.expectsError( + () => crypto.setEngine(notExistsEngineName), + { + code: 'ERR_CRYPTO_ENGINE_UNKNOWN', + type: Error, + message: `Engine "${notExistsEngineName}" was not found` + }); + +common.expectsError( + () => crypto.setEngine(notExistsEngineName, + crypto.constants.ENGINE_METHOD_RSA), + { + code: 'ERR_CRYPTO_ENGINE_UNKNOWN', + type: Error, + message: `Engine "${notExistsEngineName}" was not found` + }); From 8eebb2f42620307f6949d8109f3bb739e4ae2361 Mon Sep 17 00:00:00 2001 From: Leko Date: Sat, 2 Dec 2017 17:01:05 +0900 Subject: [PATCH 2/2] test: rename notExistsEngineName to invalidEngineName --- test/parallel/test-crypto-engine.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-crypto-engine.js b/test/parallel/test-crypto-engine.js index 99ab42174d1acc..43f8b8084c7fe9 100644 --- a/test/parallel/test-crypto-engine.js +++ b/test/parallel/test-crypto-engine.js @@ -5,7 +5,7 @@ if (!common.hasCrypto) common.skip('missing crypto'); const crypto = require('crypto'); -const notExistsEngineName = 'xxx'; +const invalidEngineName = 'xxx'; common.expectsError( () => crypto.setEngine(true), @@ -24,18 +24,17 @@ common.expectsError( }); common.expectsError( - () => crypto.setEngine(notExistsEngineName), + () => crypto.setEngine(invalidEngineName), { code: 'ERR_CRYPTO_ENGINE_UNKNOWN', type: Error, - message: `Engine "${notExistsEngineName}" was not found` + message: `Engine "${invalidEngineName}" was not found` }); common.expectsError( - () => crypto.setEngine(notExistsEngineName, - crypto.constants.ENGINE_METHOD_RSA), + () => crypto.setEngine(invalidEngineName, crypto.constants.ENGINE_METHOD_RSA), { code: 'ERR_CRYPTO_ENGINE_UNKNOWN', type: Error, - message: `Engine "${notExistsEngineName}" was not found` + message: `Engine "${invalidEngineName}" was not found` });