-
Notifications
You must be signed in to change notification settings - Fork 30k
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: http test improvements #14315
test: http test improvements #14315
Conversation
a03f0e0
to
8f50438
Compare
assert.strictEqual('GET', req.method); | ||
assert.strictEqual('/blah', req.url); | ||
assert.deepStrictEqual({ | ||
host: 'mapdevel.trolologames.ru:443', |
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.
heh
server.listen(0, function() { | ||
name = http.globalAgent.getName({ port: this.address().port }); | ||
for (let i = 0; i < max; ++i) { | ||
}, 3)); |
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.
Why did you add this?
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.
Just tightening up the tests to be more strict.
assert.throws(() => { | ||
http.request({ method: input, path: '/' }, common.mustNotCall()); | ||
http.request({ method: method, path: '/' }, 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.
this can be a shorthand. { method, path: '/'}
. Also this test structure is a bit strange - and I'm not sure that in this case the code is clearer after the refactoring. Personally I would prefer a for... of
but it's not a big deal.
assert.throws(() => { | ||
http.request({ method: input, path: '/' }, common.mustNotCall()); | ||
http.request({ method: method, path: '/' }, common.mustNotCall()); | ||
}, /^TypeError: Method must be a string$/); |
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.
It might be good to add a Symbol
to the list of expectedFails while we're touching these
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.
Left a few nits - overall nice work with the countdown.
This is also a pretty big diff.
/cc @nodejs/testing @nodejs/http |
efcd158
to
582ce9b
Compare
@benjamingr ... nits addressed! |
It seems this should be added before the code example in <!-- eslint-disable strict, required-modules --> |
582ce9b
to
1fccc7b
Compare
* Add common/countdown utility * Numerous improvements to http tests
1fccc7b
to
9062d47
Compare
* Add common/countdown utility * Numerous improvements to http tests PR-URL: #14315 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Landed in b0a8a7c, squashed and a lint issue fixed in the process. |
@nodejs/codeandlearn ... As a future exercise for code-n-learn participants, there are a non-trivial number of existing tests that can be modified to use the new common/countdown module... for instance, to shutdown a server after a given number of test requests have completed. |
This doesn’t land cleanly on 8.x; if you can, please follow the guide and raise a backport PR. |
* Add common/countdown utility * Numerous improvements to http tests PR-URL: nodejs#14315 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This does not land cleanly in LTS. Please feel free to manually backport by following the guide. Please also feel free to replace do-not-land if it is being backported |
* Add common/countdown utility * Numerous improvements to http tests PR-URL: #14315 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Generalized http test suite improvements...
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test