Skip to content

Commit 85e6271

Browse files
mithunsasidharanMylesBorins
authored andcommitted
test: use Countdown in http test
PR-URL: #17436 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 8c81ba0 commit 85e6271

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

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

+3-8
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)