From e36d43f55b877c01d4be98ae2b7f153ff943d96c Mon Sep 17 00:00:00 2001 From: Leko Date: Sat, 2 Dec 2017 03:10:26 +0900 Subject: [PATCH] test: add test case for missing branch - The case of id is string, flags is number - The case of flags is not 0 PR-URL: https://github.com/nodejs/node/pull/17418 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Anatoli Papirovski Reviewed-By: Luigi Pinca Reviewed-By: Jon Moss --- test/parallel/test-crypto-engine.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/parallel/test-crypto-engine.js b/test/parallel/test-crypto-engine.js index b731ec2f0372fa..43f8b8084c7fe9 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 invalidEngineName = 'xxx'; common.expectsError( () => crypto.setEngine(true), @@ -21,3 +22,19 @@ common.expectsError( type: TypeError, message: 'The "flags" argument must be of type number' }); + +common.expectsError( + () => crypto.setEngine(invalidEngineName), + { + code: 'ERR_CRYPTO_ENGINE_UNKNOWN', + type: Error, + message: `Engine "${invalidEngineName}" was not found` + }); + +common.expectsError( + () => crypto.setEngine(invalidEngineName, crypto.constants.ENGINE_METHOD_RSA), + { + code: 'ERR_CRYPTO_ENGINE_UNKNOWN', + type: Error, + message: `Engine "${invalidEngineName}" was not found` + });