Skip to content

Commit 91649b9

Browse files
TrottMylesBorins
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 9ed2c4c commit 91649b9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/parallel/test-tls-connect.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'use strict';
22
const common = require('../common');
3-
const assert = require('assert');
43

54
if (!common.hasCrypto)
65
common.skip('missing crypto');
76

8-
const tls = require('tls');
7+
const assert = require('assert');
98
const fs = require('fs');
109
const path = require('path');
10+
const tls = require('tls');
1111

1212
// https://github.com/joyent/node/issues/1218
1313
// uncatchable exception on TLS connection error
@@ -18,7 +18,10 @@ const path = require('path');
1818
const options = {cert: cert, key: key, port: common.PORT};
1919
const conn = tls.connect(options, common.fail);
2020

21-
conn.on('error', common.mustCall());
21+
conn.on(
22+
'error',
23+
common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNREFUSED'); })
24+
);
2225
}
2326

2427
// SSL_accept/SSL_connect error handling
@@ -35,5 +38,8 @@ const path = require('path');
3538
assert.ok(false); // callback should never be executed
3639
});
3740

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

0 commit comments

Comments
 (0)