Skip to content

Commit cea4bd9

Browse files
Trottaddaleax
authored andcommitted
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: #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]>
1 parent c80d400 commit cea4bd9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/parallel/test-tls-connect.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ const common = require('../common');
2525
if (!common.hasCrypto)
2626
common.skip('missing crypto');
2727

28-
const tls = require('tls');
28+
const assert = require('assert');
2929
const fs = require('fs');
3030
const path = require('path');
31+
const tls = require('tls');
3132

3233
// https://github.com/joyent/node/issues/1218
3334
// uncatchable exception on TLS connection error
@@ -38,7 +39,10 @@ const path = require('path');
3839
const options = { cert: cert, key: key, port: common.PORT };
3940
const conn = tls.connect(options, common.mustNotCall());
4041

41-
conn.on('error', common.mustCall());
42+
conn.on(
43+
'error',
44+
common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNREFUSED'); })
45+
);
4246
}
4347

4448
// SSL_accept/SSL_connect error handling
@@ -53,5 +57,8 @@ const path = require('path');
5357
ciphers: 'rick-128-roll'
5458
}, common.mustNotCall());
5559

56-
conn.on('error', common.mustCall());
60+
conn.on(
61+
'error',
62+
common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNREFUSED'); })
63+
);
5764
}

0 commit comments

Comments
 (0)