Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 85e6271

Browse filesBrowse files
mithunsasidharanMylesBorins
authored andcommitted
test: use Countdown in http test
PR-URL: #17436 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 8c81ba0 commit 85e6271
Copy full SHA for 85e6271

File tree

Expand file treeCollapse file tree

1 file changed

+3
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-8
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-http-response-multi-content-length.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-response-multi-content-length.js
+3-8Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const common = require('../common');
44
const http = require('http');
55
const assert = require('assert');
6+
const Countdown = require('../common/countdown');
67

78
const MAX_COUNT = 2;
89

@@ -24,7 +25,7 @@ const server = http.createServer((req, res) => {
2425
res.end('ok');
2526
});
2627

27-
let count = 0;
28+
const countdown = new Countdown(MAX_COUNT, () => server.close());
2829

2930
server.listen(0, common.mustCall(() => {
3031
for (let n = 1; n <= MAX_COUNT; n++) {
@@ -40,13 +41,7 @@ server.listen(0, common.mustCall(() => {
4041
).on('error', common.mustCall((err) => {
4142
assert(/^Parse Error/.test(err.message));
4243
assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
43-
count++;
44-
if (count === MAX_COUNT)
45-
server.close();
44+
countdown.dec();
4645
}));
4746
}
4847
}));
49-
50-
process.on('exit', () => {
51-
assert.strictEqual(count, MAX_COUNT);
52-
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.