Skip to content

Commit

Permalink
test: fix test-http-status-reason-invalid-chars
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
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
saitoxu authored and addaleax committed Dec 8, 2016
1 parent d1f5e99 commit 6105c91
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 6105c91

Please sign in to comment.