Skip to content

Commit 68dabce

Browse files
shilomagengibfahn
authored andcommitted
test: use Countdown in test-http-set-cookies
PR-URL: #17504 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Jon Moss <[email protected]>
1 parent d4d3f50 commit 68dabce

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

test/parallel/test-http-set-cookies.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
require('../common');
33
const assert = require('assert');
44
const http = require('http');
5+
const Countdown = require('../common/countdown');
56

6-
let nresponses = 0;
7-
7+
const countdown = new Countdown(2, () => server.close());
88
const server = http.createServer(function(req, res) {
99
if (req.url === '/one') {
1010
res.writeHead(200, [['set-cookie', 'A'],
@@ -34,9 +34,7 @@ server.on('listening', function() {
3434
});
3535

3636
res.on('end', function() {
37-
if (++nresponses === 2) {
38-
server.close();
39-
}
37+
countdown.dec();
4038
});
4139
});
4240

@@ -51,14 +49,8 @@ server.on('listening', function() {
5149
});
5250

5351
res.on('end', function() {
54-
if (++nresponses === 2) {
55-
server.close();
56-
}
52+
countdown.dec();
5753
});
5854
});
5955

6056
});
61-
62-
process.on('exit', function() {
63-
assert.strictEqual(2, nresponses);
64-
});

0 commit comments

Comments
 (0)