-
-
Notifications
You must be signed in to change notification settings - Fork 32k
test: refactor test-http-information-processing #32547
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,22 +2,21 @@ | |
require('../common'); | ||
const assert = require('assert'); | ||
const http = require('http'); | ||
const Countdown = require('../common/countdown'); | ||
|
||
const test_res_body = 'other stuff!\n'; | ||
const countdown = new Countdown(3, () => server.close()); | ||
const testResBody = 'other stuff!\n'; | ||
const kMessageCount = 2; | ||
|
||
const server = http.createServer((req, res) => { | ||
console.error('Server sending informational message #1...'); | ||
res.writeProcessing(); | ||
console.error('Server sending informational message #2...'); | ||
res.writeProcessing(); | ||
for (let i = 0; i < kMessageCount; i++) { | ||
console.error(`Server sending informational message #${i}...`); | ||
res.writeProcessing(); | ||
} | ||
console.error('Server sending full response...'); | ||
res.writeHead(200, { | ||
'Content-Type': 'text/plain', | ||
'ABCD': '1' | ||
}); | ||
res.end(test_res_body); | ||
res.end(testResBody); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could, but I'm not sure we should. This test isn't checking to see if This makes it sound like I'm much more opposed to the idea than I actually am. I'm on the fence, around a -0 or so. I was a -1 about 10 minutes ago, so 10 minutes from now, I'll probably be an enthusiastic +1. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
correct me if I am wrong, but isn't that the case with most of 100+ http test cases?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not seeing that with
I don't think we should add a check for a callback here that we're not using. Again, I'm not strongly opposed, but I am mildly resistant. 😀 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used this command |
||
}); | ||
|
||
server.listen(0, function() { | ||
|
@@ -29,24 +28,22 @@ server.listen(0, function() { | |
console.error('Client sending request...'); | ||
|
||
let body = ''; | ||
let infoCount = 0; | ||
|
||
req.on('information', function(res) { | ||
console.error('Client got 102 Processing...'); | ||
countdown.dec(); | ||
}); | ||
req.on('information', () => { infoCount++; }); | ||
Trott marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
req.on('response', function(res) { | ||
// Check that all 102 Processing received before full response received. | ||
assert.strictEqual(countdown.remaining, 1); | ||
assert.strictEqual(infoCount, kMessageCount); | ||
assert.strictEqual(res.statusCode, 200, | ||
`Final status code was ${res.statusCode}, not 200.`); | ||
res.setEncoding('utf8'); | ||
res.on('data', function(chunk) { body += chunk; }); | ||
res.on('end', function() { | ||
console.error('Got full response.'); | ||
assert.strictEqual(body, test_res_body); | ||
assert.strictEqual(body, testResBody); | ||
assert.ok('abcd' in res.headers); | ||
countdown.dec(); | ||
server.close(); | ||
}); | ||
}); | ||
}); |
Uh oh!
There was an error while loading. Please reload this page.