Skip to content

Commit

Permalink
test: use Countdown in test-http-set-cookies
Browse files Browse the repository at this point in the history
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
shilomagen authored and MylesBorins committed Dec 12, 2017
1 parent 715baf8 commit 919625b
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions test/parallel/test-http-set-cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,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'],
Expand Down Expand Up @@ -55,9 +55,7 @@ server.on('listening', function() {
});

res.on('end', function() {
if (++nresponses === 2) {
server.close();
}
countdown.dec();
});
});

Expand All @@ -72,14 +70,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 919625b

Please sign in to comment.