Permalink
Browse files

test: use Countdown in test-http-set-cookies

PR-URL: #17504
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
  • Loading branch information...
shilomangam authored and gibfahn committed Dec 6, 2017
1 parent d4d3f50 commit 68dabce07a9e02b27351091cd03bdb0241f508d5
Showing with 4 additions and 12 deletions.
  1. +4 −12 test/parallel/test-http-set-cookies.js
@@ -2,9 +2,9 @@
require('../common');
const assert = require('assert');
const http = require('http');
const Countdown = require('../common/countdown');
let nresponses = 0;
const countdown = new Countdown(2, () => server.close());
const server = http.createServer(function(req, res) {
if (req.url === '/one') {
res.writeHead(200, [['set-cookie', 'A'],
@@ -34,9 +34,7 @@ server.on('listening', function() {
});
res.on('end', function() {
if (++nresponses === 2) {
server.close();
}
countdown.dec();
});
});
@@ -51,14 +49,8 @@ server.on('listening', function() {
});
res.on('end', function() {
if (++nresponses === 2) {
server.close();
}
countdown.dec();
});
});
});
process.on('exit', function() {
assert.strictEqual(2, nresponses);
});

0 comments on commit 68dabce

Please sign in to comment.