-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: improve the code in test-http-chunked-304 #10462
Conversation
if (next) process.nextTick(next); | ||
conn.on('end', common.mustCall(function() { | ||
assert.strictEqual(/^Connection: close\r\n$/m.test(resp), true); | ||
assert.strictEqual(/^0\r\n$/m.test(resp), false); |
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 am not sure what exactly this tests.
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.
@thefourtheye as I see it, this is testing this code: https://github.com/nodejs/node/blob/master/lib/_http_outgoing.js#L255-L279 , so Connection: close
should be in the resp and as the comment there says : // Make sure we don't end the 0\r\n\r\n at the end of the message.
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.
Perhaps add that information as a comment to the test?
@@ -12,32 +12,33 @@ var net = require('net'); | |||
// Likewise for 304 responses. Verify that no empty chunk is sent when | |||
// the user explicitly sets a Transfer-Encoding header. | |||
|
|||
test(204, function() { | |||
test(204, () => { | |||
test(304); |
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 am not a big fan of nesting functions unless it is unavoidable. Now that we have common.mustCall
to ensure that assertions will happen for sure, why don't we refactor this to sequential calls?
@Trott Added the comments clarifying the assertions, @thefourtheye changed the nested functions to run in parallel |
conn.on('end', common.mustCall(function() { | ||
// Connection: close should be in the response | ||
assert.strictEqual(/^Connection: close\r\n$/m.test(resp), true); | ||
// Make sure this don't end with 0\r\n\r\n |
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.
Totally unimportant nit that should not stop this from landing but if you want to fix it up, go for it:
don't
-> doesn't
@Trott , sorry about that... just fixed it 🙂 |
I think there is a git commit problem. I see two changed files. |
@thefourtheye you are right, sorry about that handling too many branches and I made a mistake, just fixed it... |
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.
CI Run: https://ci.nodejs.org/job/node-test-pull-request/5616/
Just to be sure :-)
conn.write('GET / HTTP/1.1\r\n\r\n'); | ||
server.listen(0, common.mustCall(function() { | ||
const conn = net.createConnection(this.address().port, | ||
common.mustCall(() => { |
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.
Linter is not happy with this indentation.
* change the nested functions call to run tests in parallel * use const and let instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions
var conn = net.createConnection(this.address().port, function() { | ||
conn.write('GET / HTTP/1.1\r\n\r\n'); | ||
server.listen(0, common.mustCall(() => { | ||
const conn = net.createConnection( |
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 didn't get an error before with make -j8 lint
, but changed it this way to make it look better, same.. no error with make -j8 lint
, let me know if this way works or if not please provide an example and will make it fit
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 works now, thanks.
Landed in f895715. |
* change the nested functions call to run tests in parallel * use const and let instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: #10462 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* change the nested functions call to run tests in parallel * use const and let instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: nodejs#10462 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* change the nested functions call to run tests in parallel * use const and let instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: nodejs#10462 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* change the nested functions call to run tests in parallel * use const and let instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: nodejs#10462 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* change the nested functions call to run tests in parallel * use const and let instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: nodejs#10462 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* change the nested functions call to run tests in parallel * use const and let instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: #10462 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* change the nested functions call to run tests in parallel * use const and let instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: #10462 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* change the nested functions call to run tests in parallel * use const and let instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: #10462 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* change the nested functions call to run tests in parallel * use const and let instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: #10462 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test
Description of change