Skip to content

Commit

Permalink
test: make test-tls-connect checks more strict
Browse files Browse the repository at this point in the history
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: #14695
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
Trott authored and MylesBorins committed Sep 19, 2017
1 parent 9ed2c4c commit 91649b9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/parallel/test-tls-connect.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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'); })
);
}

0 comments on commit 91649b9

Please sign in to comment.