Skip to content

Commit d51c856

Browse files
saitoxuaddaleax
authored andcommitted
test: fix test-http-status-reason-invalid-chars
Use port 0 instead of common.PORT, and use server address instead of localhost to follow writing test guideline. This is a part of Code And Learn at NodeFest 2016 Challenge in Tokyo. PR-URL: #9572 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Shigeki Ohtsu <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 2ee3543 commit d51c856

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/parallel/test-http-status-reason-invalid-chars.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const common = require('../common');
44
const assert = require('assert');
55
const http = require('http');
6+
const net = require('net');
67

78
function explicit(req, res) {
89
assert.throws(() => {
@@ -32,8 +33,10 @@ const server = http.createServer((req, res) => {
3233
} else {
3334
implicit(req, res);
3435
}
35-
}).listen(common.PORT, common.mustCall(() => {
36-
const url = `http://localhost:${common.PORT}`;
36+
}).listen(0, common.mustCall(() => {
37+
const addr = server.address().address;
38+
const hostname = net.isIPv6(addr) ? `[${addr}1]` : addr;
39+
const url = `http://${hostname}:${server.address().port}`;
3740
let left = 2;
3841
const check = common.mustCall((res) => {
3942
left--;

0 commit comments

Comments
 (0)