From 91649b913c4beb730fbb3f4e2035f9cf1f60b18e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 8 Aug 2017 09:53:55 -0700 Subject: [PATCH] test: make test-tls-connect checks more strict MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check the error code on expected errors so that the introduction of different errors in refactoring is caught. While at it, re-order modules alphabetically per test-writing guide. PR-URL: https://github.com/nodejs/node/pull/14695 Reviewed-By: Refael Ackermann Reviewed-By: Tobias Nießen Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- test/parallel/test-tls-connect.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-tls-connect.js b/test/parallel/test-tls-connect.js index b410f86180e00b..1419bd3a5ea427 100644 --- a/test/parallel/test-tls-connect.js +++ b/test/parallel/test-tls-connect.js @@ -1,13 +1,13 @@ 'use strict'; const common = require('../common'); -const assert = require('assert'); if (!common.hasCrypto) common.skip('missing crypto'); -const tls = require('tls'); +const assert = require('assert'); const fs = require('fs'); const path = require('path'); +const tls = require('tls'); // https://github.com/joyent/node/issues/1218 // uncatchable exception on TLS connection error @@ -18,7 +18,10 @@ const path = require('path'); const options = {cert: cert, key: key, port: common.PORT}; const conn = tls.connect(options, common.fail); - conn.on('error', common.mustCall()); + conn.on( + 'error', + common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNREFUSED'); }) + ); } // SSL_accept/SSL_connect error handling @@ -35,5 +38,8 @@ const path = require('path'); assert.ok(false); // callback should never be executed }); - conn.on('error', common.mustCall()); + conn.on( + 'error', + common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNREFUSED'); }) + ); }