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

Adding a test for undefined value in OutgoingMessage.setHeader #970

Closed
wants to merge 1 commit into from

Conversation

kenperkins
Copy link
Contributor

As a result of 979d0ca there is a new check for undefined values on
OutgoingMessage.setHeader. This commit introduces a test for this case.

As a result of 979d0ca there is a new check for undefined values on
OutgoingMessage.setHeader. This commit introduces a test for this case.
@rvagg
Copy link
Member

rvagg commented Feb 26, 2015

lgtm

@@ -18,6 +18,17 @@ var s = http.createServer(function(req, res) {
}
assert.ok(threw, 'Non-string names should throw');

// undefined value should throw, via 979d0ca8
threw = false;
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just use assert.throws()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just quickly duplicated the section above. I'm open to suggestions here.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it would make more sense to use assert.throws() with a validation function like:

function(err) {
  return err instanceof Error && err.message === '`value` required in setHeader("foo", value).';
}

Copy link
Member

Choose a reason for hiding this comment

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

Truth be told, I think the try/catch is more readable.

Copy link
Contributor

Choose a reason for hiding this comment

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

as it is the same style as the above section, @cjihrig would you object to me merging this in as-is?

Copy link
Contributor

Choose a reason for hiding this comment

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

@brendanashworth go for it.

@brendanashworth
Copy link
Contributor

looks good to me

brendanashworth pushed a commit that referenced this pull request Mar 5, 2015
As a result of 979d0ca there is a new check for undefined values on
OutgoingMessage.setHeader. This commit introduces a test for this case.

PR-URL: #970
Reviewed-By: Rod Vagg <[email protected]>
Reviewed-By: Brendan Ashworth <[email protected]>
@brendanashworth
Copy link
Contributor

Thanks @kenperkins, merged in b72fa03! (with modified commit message)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants