Browse Source

test: make test-tls-connect checks more strict

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 <refack@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v6
Rich Trott 7 years ago
committed by Anna Henningsen
parent
commit
cea4bd92fd
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 13
      test/parallel/test-tls-connect.js

13
test/parallel/test-tls-connect.js

@ -25,9 +25,10 @@ const common = require('../common');
if (!common.hasCrypto) if (!common.hasCrypto)
common.skip('missing crypto'); common.skip('missing crypto');
const tls = require('tls'); const assert = require('assert');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const tls = require('tls');
// https://github.com/joyent/node/issues/1218 // https://github.com/joyent/node/issues/1218
// uncatchable exception on TLS connection error // uncatchable exception on TLS connection error
@ -38,7 +39,10 @@ const path = require('path');
const options = { cert: cert, key: key, port: common.PORT }; const options = { cert: cert, key: key, port: common.PORT };
const conn = tls.connect(options, common.mustNotCall()); const conn = tls.connect(options, common.mustNotCall());
conn.on('error', common.mustCall()); conn.on(
'error',
common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNREFUSED'); })
);
} }
// SSL_accept/SSL_connect error handling // SSL_accept/SSL_connect error handling
@ -53,5 +57,8 @@ const path = require('path');
ciphers: 'rick-128-roll' ciphers: 'rick-128-roll'
}, common.mustNotCall()); }, common.mustNotCall());
conn.on('error', common.mustCall()); conn.on(
'error',
common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNREFUSED'); })
);
} }

Loading…
Cancel
Save