-
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: Refactor test-http2-compat-serverresponse-finished.js #21929
Conversation
assert.strictEqual(response.socket, undefined); | ||
assert.strictEqual(response.connection, undefined); | ||
response.on('finish', common.mustCall(() => { | ||
assert.ok(!response.socket); |
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.
I see this kind of change being done frequently recently and I think this is not always a good idea. If there are other tests that cover the real value then it's ok, if not we are hiding the real type by coercing to a boolean.
What I mean is that if a regression is introduced where response.socket
is set to null
(or any other falsy value) instead of undefined
, with this change, we will not notice.
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.
@lpinca I got your point. I even thought about it before I did the changes, but in this context, when the response is finished
, its gonna be undefined
. So socket
and connection
are no more valid, I felt it was fine to use ok
. But yeah, if some other logic expects the socket
to be undefined
and we pass null
, we gonna cause a regression. Good point.
e9106e1
to
96a8979
Compare
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.
I agree with lpinca's point about the assert.ok
though.
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.
LGTM, but please change the assert.ok()
calls back. I think it's fine for language-level APIs, but we should be more strict with the APIs we provide for the reasons previously noted.
ping @antsmartian |
@maclover7 Oops, sorry. Will update the PR in an hour or so. |
@maclover7 Ping :) |
Landed in f2518c4 |
PR-URL: #21929 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #21929 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: nodejs#21929 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: nodejs#21929 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Backport-PR-URL: #22850 PR-URL: #21929 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Just a simple refactor change:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes