Skip to content

Commit

Permalink
test: fix test-http-status-reason-invalid-chars.js
Browse files Browse the repository at this point in the history
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
  • Loading branch information
saitoxu committed Nov 18, 2016
1 parent c184f22 commit 00597b3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/parallel/test-http-status-reason-invalid-chars.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const common = require('../common');
const assert = require('assert');
const http = require('http');
const net = require('net');

function explicit(req, res) {
assert.throws(() => {
Expand Down Expand Up @@ -32,8 +33,10 @@ const server = http.createServer((req, res) => {
} else {
implicit(req, res);
}
}).listen(common.PORT, common.mustCall(() => {
const url = `http://localhost:${common.PORT}`;
}).listen(0, common.mustCall(() => {
const addr = server.address().address;
const hostname = net.isIPv6(addr) ? `[${addr}1]` : addr;
const url = `http://${hostname}:${server.address().port}`;
let left = 2;
const check = common.mustCall((res) => {
left--;
Expand Down

0 comments on commit 00597b3

Please sign in to comment.