Skip to content
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: add case to test-http-methods.js #14773

Closed
wants to merge 3 commits into from

Conversation

oantoro
Copy link
Contributor

@oantoro oantoro commented Aug 11, 2017

Add more case to check existence of DELETE and PUT methods.

Refs: #14544

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

test http

Add more case to check existence of DELETE and PUT methods.

Refs: nodejs#14544
@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Aug 11, 2017
@aqrln aqrln added the http Issues or PRs related to the http subsystem. label Aug 11, 2017
@aqrln
Copy link
Contributor

aqrln commented Aug 11, 2017

Hi and thanks for your contribution! This looks good, and is certainly an improvement to the test, but I wonder if it would be even better to check that all request methods Node's HTTP parser supports are properly exposed. That said, you or anyone else may do it as a separate PR, so LGTM either way.

@oantoro
Copy link
Contributor Author

oantoro commented Aug 11, 2017

Hi @aqrln @tniessen
I just updated the test case. to cover all methods in HTTP parser. I built array and just use deep equal to check the existence of the methods. Is it okay?

Copy link
Contributor

@aqrln aqrln left a comment

Choose a reason for hiding this comment

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

@okyantoro yes, this approach is perfectly okay. I left a bunch of comments, sorry if it's a bit overwhelming, and let me know if you need any help. Thanks!

// This test ensures all http methods from HTTP parser are exposed
// to http library

var methods = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: use const

'MKCALENDAR',
'LINK',
'UNLINK'
];
assert(Array.isArray(http.METHODS));
assert(http.METHODS.length > 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

This check is now redundant, you may safely remove it.

assert(http.METHODS.includes('POST'));
assert(http.METHODS.includes('PUT'));
assert.deepStrictEqual(util._extend([], http.METHODS), http.METHODS.sort());
assert.equal(methods.length, http.METHODS.length);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is covered by the next assert statement, so I'd say this is redundant. By the way, please use strictEqual() instead of equal() in such cases :)

assert(http.METHODS.includes('PUT'));
assert.deepStrictEqual(util._extend([], http.METHODS), http.METHODS.sort());
assert.equal(methods.length, http.METHODS.length);
assert.deepStrictEqual(methods.sort(), http.METHODS.sort());
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously this test asserted that the http.METHODS array is alphabetically sorted. So as not to change the test expectations, you should either drop .sort() from http.METHODS, or drop both .sort()s and make the array in this test sorted beforehand. I'd prefer the latter way, but one might find the former one conveying the intention more clearly, so I'm fine with both.

Copy link
Contributor

Choose a reason for hiding this comment

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

Aside from that, can you please swap the order of arguments here? According to the function's signature, first argument should be an actual value and second one an expected value.

@oantoro
Copy link
Contributor Author

oantoro commented Aug 12, 2017

@aqrln I just updated it. Thanks

Copy link
Contributor

@aqrln aqrln left a comment

Choose a reason for hiding this comment

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

aqrln pushed a commit that referenced this pull request Aug 14, 2017
Cover all request methods that Node's HTTP parser supports in
parallel/test-http-methods.

PR-URL: #14773
Refs: #14544
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@aqrln
Copy link
Contributor

aqrln commented Aug 14, 2017

Landed in 1268737. Thanks, and hope to see you contributing again!

@aqrln aqrln closed this Aug 14, 2017
@oantoro oantoro deleted the test-http-methods branch August 14, 2017 07:22
addaleax pushed a commit that referenced this pull request Aug 14, 2017
Cover all request methods that Node's HTTP parser supports in
parallel/test-http-methods.

PR-URL: #14773
Refs: #14544
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@addaleax addaleax mentioned this pull request Aug 14, 2017
MylesBorins pushed a commit that referenced this pull request Sep 20, 2017
Cover all request methods that Node's HTTP parser supports in
parallel/test-http-methods.

PR-URL: #14773
Refs: #14544
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants