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 <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
  • Loading branch information
shilomagen authored and gibfahn committed Dec 20, 2017
1 parent d4d3f50 commit 68dabce
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 @@ -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'],
Expand Down Expand Up @@ -34,9 +34,7 @@ server.on('listening', function() {
});

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

Expand All @@ -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.