-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: fix assert.throws in test-http-invalid-urls #15678
Conversation
|
||
function test(host) { | ||
['get', 'request'].forEach((method) => { | ||
[http, https].forEach((module) => { | ||
assert.throws(() => module[method](host, () => { | ||
common.expectsError(() => module[method](host, () => { | ||
throw new Error(`${module}.${method} should not connect to ${host}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: how about replacing this with common.mustNotCall()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. And while I'm at it, I can add {
and }
around the arrow function body because there's no need for it to implicitly return a value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found other problems in the process. Refactored/fixed/commented in the commit message.
f19a178
to
5db3a8b
Compare
When the second argument to `assert.throws()` is a string, it is not treated as the expected error message but rather the message that the assertion should display if no error is thrown. Ths change fixes that error in `test-http-invalid-urls.js`. Instead of skipping the test when there is no crypto, the test is now run but with `http` only. `https` is skipped. Logging was fixed. Previously, errors would be written out as being in the `[object Object]` module rather than `http` or `https`.
5db3a8b
to
a263630
Compare
Landed in 2e215f1 |
When the second argument to `assert.throws()` is a string, it is not treated as the expected error message but rather the message that the assertion should display if no error is thrown. Ths change fixes that error in `test-http-invalid-urls.js`. Instead of skipping the test when there is no crypto, the test is now run but with `http` only. `https` is skipped. Logging was fixed. Previously, errors would be written out as being in the `[object Object]` module rather than `http` or `https`. PR-URL: #15678 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
When cherry-picked to 8.x this test is failing. Could you please backport |
@MylesBorins The test change is dependent on #14423 which is semver-major. I'll label this "dont-land" on 8, 6, and 4. |
When the second argument to `assert.throws()` is a string, it is not treated as the expected error message but rather the message that the assertion should display if no error is thrown. Ths change fixes that error in `test-http-invalid-urls.js`. Instead of skipping the test when there is no crypto, the test is now run but with `http` only. `https` is skipped. Logging was fixed. Previously, errors would be written out as being in the `[object Object]` module rather than `http` or `https`. PR-URL: nodejs/node#15678 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
When the second argument to
assert.throws()
is a string, it is nottreated as the expected error message but rather the message that the
assertion should display if no error is thrown. Ths change fixes that
error in
test-http-invalid-urls.js
.Instead of skipping the test when there is no crypto, the test is now
run but with
http
only.https
is skipped.Logging was fixed. Previously, errors would be written out as being in
the
[object Object]
module rather thanhttp
orhttps
.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test