Skip to content

Commit 919625b

Browse files
shilomagenMylesBorins
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 715baf8 commit 919625b

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

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

+4-12
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
require('../common');
2424
const assert = require('assert');
2525
const http = require('http');
26+
const Countdown = require('../common/countdown');
2627

27-
let nresponses = 0;
28-
28+
const countdown = new Countdown(2, () => server.close());
2929
const server = http.createServer(function(req, res) {
3030
if (req.url === '/one') {
3131
res.writeHead(200, [['set-cookie', 'A'],
@@ -55,9 +55,7 @@ server.on('listening', function() {
5555
});
5656

5757
res.on('end', function() {
58-
if (++nresponses === 2) {
59-
server.close();
60-
}
58+
countdown.dec();
6159
});
6260
});
6361

@@ -72,14 +70,8 @@ server.on('listening', function() {
7270
});
7371

7472
res.on('end', function() {
75-
if (++nresponses === 2) {
76-
server.close();
77-
}
73+
countdown.dec();
7874
});
7975
});
8076

8177
});
82-
83-
process.on('exit', function() {
84-
assert.strictEqual(2, nresponses);
85-
});

0 commit comments

Comments
 (0)