FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: update test-http-status-code to use countdown by onneri · Pull Request #17477 · nodejs/node · GitHub

/ node Public

test: update test-http-status-code to use countdown - #17477

Closed
onneri wants to merge 2 commits into
nodejs:masterfrom
onneri:converting-tests-to-use-countdown
Closed

test: update test-http-status-code to use countdown#17477
onneri wants to merge 2 commits into
nodejs:masterfrom
onneri:converting-tests-to-use-countdown

Conversation

onneri commented Dec 6, 2017
edited by apapirovski
Loading

Copy link
Copy Markdown
Contributor

The test was changed to use countdown instead of validating
if the index of the array of codes exceeded the size of the
array.

Also the validation that was before didn't allow to execute
the last test, so the assert equal was to 5, and the last
status in the array wasn't tested. The change was to
assert 6 tests complete.

Refs: #17169

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

The test was changed to use countdown instead of validating
if the index of the array of codes exceeded the size of the
array.

Also the validation that was before didn't allow to execute
the last test, so the assert equal was to 5, and the last
status in the array wasn't tested. The change was to
assert 6 tests complete.

Fixes: nodejs#17169
nodejs-github-bot added the test Issues and PRs related to the tests. label Dec 6, 2017
Comment thread test/parallel/test-http-status-code.js Outdated

process.on('exit', function() {
assert.strictEqual(5, testsComplete);
assert.strictEqual(6, testsComplete);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

How about replacing 6 with tests.length ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This code can actually be removed, as well as the testsComplete variable. Since there's a Countdown now, there's no need to verify that all 6 test cases executed.

apapirovski left a comment
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM but some small changes needed

Thank you for taking this on!

Comment thread test/parallel/test-http-status-code.js Outdated

process.on('exit', function() {
assert.strictEqual(5, testsComplete);
assert.strictEqual(6, testsComplete);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This code can actually be removed, as well as the testsComplete variable. Since there's a Countdown now, there's no need to verify that all 6 test cases executed.

Comment thread test/parallel/test-http-status-code.js Outdated
if (testIdx + 1 === tests.length) {
return s.close();
}
const test = tests[testIdx];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We can just do test = tests.shift() here (and not declare it as a const).

Comment thread test/parallel/test-http-status-code.js Outdated

let testsComplete = 0;
const tests = [200, 202, 300, 404, 451, 500];
let testIdx = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

testsComplete and testIdx can be removed. Instead add let test;.

Comment thread test/parallel/test-http-status-code.js Outdated
const countdown = new Countdown(tests.length, () => s.close());

const s = http.createServer(function(req, res) {
const t = tests[testIdx];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This can be removed and then the assert.strictEqual() can compare to the top scope test variable.

Comment thread test/parallel/test-http-status-code.js Outdated
@@ -55,13 +54,14 @@ function nextTest() {
response.on('end', function() {
testsComplete++;
testIdx += 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

These variable additions would both be removed.

The test was changed to use countdown instead of validating
if the index of the array of codes exceeded the size of the
array.

Also the validation that was before didn't allow to execute
the last test, so the assert equal was to 5, and the last
status in the array wasn't tested. The change was to
assert 6 tests complete.

Variable testIdx to manage index in array removed, using
array shift instead to manage the actual test.
Variable testsComplete removed, not necessary, Countdown
takes care of running right amount of tests
Added a test variable that has the actual code for testing

Fixes: nodejs#17169

onneri commented Dec 6, 2017

Copy link
Copy Markdown
Contributor Author

You are right, I did't notice that assertEqual for tests completed wasn't necessary due to the Countdown variable.
I made some changes to the suggestions, if you have more comments please let me know, thank you!

apapirovski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Changes LGTM. Thank you!

Copy link
Copy Markdown
Contributor

onneri commented Dec 6, 2017
edited
Loading

Copy link
Copy Markdown
Contributor Author

One test failed, could I do something about that?, or did I do something that produced that?

Copy link
Copy Markdown
Contributor

Not your fault at all, the CI is all green as far as this PR is concerned. The failure is completely unrelated. :)

maclover7 added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Dec 8, 2017
apapirovski pushed a commit that referenced this pull request Dec 8, 2017
PR-URL: #17477
Refs: #17169
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>

Copy link
Copy Markdown
Contributor

Landed in 07549c6

Thank you for your contribution @onneri! 👍

apapirovski closed this Dec 8, 2017

onneri commented Dec 8, 2017

Copy link
Copy Markdown
Contributor Author

awesome, thank you, I'll try to contribute more times, @apapirovski what does "closed with unmerged commits" mean?

apapirovski commented Dec 8, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

@onneri We don't use GitHub's buttons for merging, we have our own process for landing PRs so it just means that we didn't merge directly from your branch. As you'll note above, there's a reference to your commit landing on the master branch ("test: update http test to use Countdown"), listed right above my comment re: landing it.

Let me know if I can provide any more info! Thanks again for helping out. Looking forward to hopefully reviewing more PRs from you in the future :)

onneri commented Dec 8, 2017

Copy link
Copy Markdown
Contributor Author

thank you again!

MylesBorins pushed a commit that referenced this pull request Dec 12, 2017
PR-URL: #17477
Refs: #17169
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
MylesBorins pushed a commit that referenced this pull request Dec 12, 2017
PR-URL: #17477
Refs: #17169
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
MylesBorins mentioned this pull request Dec 12, 2017
addaleax removed the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Dec 13, 2017
gibfahn pushed a commit that referenced this pull request Dec 20, 2017
PR-URL: #17477
Refs: #17169
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
gibfahn mentioned this pull request Dec 20, 2017
gibfahn pushed a commit that referenced this pull request Dec 20, 2017
PR-URL: #17477
Refs: #17169
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
gibfahn mentioned this pull request Dec 20, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL