Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 210d860

Browse filesBrowse files
shilomagengibfahn
authored andcommitted
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>
1 parent f9e0cb2 commit 210d860
Copy full SHA for 210d860

File tree

Expand file treeCollapse file tree

1 file changed

+4
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-12
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-http-set-cookies.js
+4-12Lines changed: 4 additions & 12 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.