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 4fb0708

Browse filesBrowse files
mithunsasidharanMylesBorins
authored andcommitted
test: refactored test-http-allow-req-after-204-res to countdown
PR-URL: #17211 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent ef25de7 commit 4fb0708
Copy full SHA for 4fb0708

File tree

Expand file treeCollapse file tree

2 files changed

+5
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-8
lines changed
Open diff view settings
Collapse file

‎test/common/countdown.js‎

Copy file name to clipboardExpand all lines: test/common/countdown.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Countdown {
1717
assert(this[kLimit] > 0, 'Countdown expired');
1818
if (--this[kLimit] === 0)
1919
this[kCallback]();
20+
return this[kLimit];
2021
}
2122

2223
get remaining() {
Collapse file

‎test/parallel/test-http-allow-req-after-204-res.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-allow-req-after-204-res.js
+4-8Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
const common = require('../common');
2424
const http = require('http');
2525
const assert = require('assert');
26+
const Countdown = require('../common/countdown');
2627

2728
// first 204 or 304 works, subsequent anything fails
2829
const codes = [204, 200];
2930

30-
// Methods don't really matter, but we put in something realistic.
31-
const methods = ['DELETE', 'DELETE'];
31+
const countdown = new Countdown(codes.length, () => server.close());
3232

3333
const server = http.createServer(common.mustCall((req, res) => {
3434
const code = codes.shift();
@@ -39,17 +39,13 @@ const server = http.createServer(common.mustCall((req, res) => {
3939
}, codes.length));
4040

4141
function nextRequest() {
42-
const method = methods.shift();
4342

44-
const request = http.request({
43+
const request = http.get({
4544
port: server.address().port,
46-
method: method,
4745
path: '/'
4846
}, common.mustCall((response) => {
4947
response.on('end', common.mustCall(() => {
50-
if (methods.length === 0) {
51-
server.close();
52-
} else {
48+
if (countdown.dec()) {
5349
// throws error:
5450
nextRequest();
5551
// works just fine:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.