Skip to content

Commit

Permalink
test: prefer server over srv
Browse files Browse the repository at this point in the history
PR-URL: #31224
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
andrewhughes101 authored and MylesBorins committed Jan 16, 2020
1 parent 220ea0c commit d76deca
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions test/parallel/test-http-server-multiheaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require('../common');
const assert = require('assert');
const http = require('http');

const srv = http.createServer(function(req, res) {
const server = http.createServer(function(req, res) {
assert.strictEqual(req.headers.accept, 'abc, def, ghijklmnopqrst');
assert.strictEqual(req.headers.host, 'foo');
assert.strictEqual(req.headers['www-authenticate'], 'foo, bar, baz');
Expand All @@ -43,10 +43,10 @@ const srv = http.createServer(function(req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('EOF');

srv.close();
server.close();
});

srv.listen(0, function() {
server.listen(0, function() {
http.get({
host: 'localhost',
port: this.address().port,
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-http-server-multiheaders2.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const multipleForbidden = [
// 'Content-Length',
];

const srv = http.createServer(function(req, res) {
const server = http.createServer(function(req, res) {
multipleForbidden.forEach(function(header) {
assert.strictEqual(req.headers[header.toLowerCase()], 'foo',
`header parsed incorrectly: ${header}`);
Expand All @@ -83,7 +83,7 @@ const srv = http.createServer(function(req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('EOF');

srv.close();
server.close();
});

function makeHeader(value) {
Expand All @@ -98,7 +98,7 @@ const headers = []
.concat(multipleAllowed.map(makeHeader('bar')))
.concat(multipleForbidden.map(makeHeader('bar')));

srv.listen(0, function() {
server.listen(0, function() {
http.get({
host: 'localhost',
port: this.address().port,
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-http-upgrade-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const http = require('http');
const net = require('net');

// Create a TCP server
const srv = net.createServer(function(c) {
const server = net.createServer(function(c) {
c.on('data', function(d) {
c.write('HTTP/1.1 101\r\n');
c.write('hello: world\r\n');
Expand All @@ -46,7 +46,7 @@ const srv = net.createServer(function(c) {
});
});

srv.listen(0, '127.0.0.1', common.mustCall(function() {
server.listen(0, '127.0.0.1', common.mustCall(function() {

const options = {
port: this.address().port,
Expand Down Expand Up @@ -82,7 +82,7 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() {

req.on('close', common.mustCall(function() {
socket.end();
srv.close();
server.close();
}));
}));
}));
6 changes: 3 additions & 3 deletions test/parallel/test-http-upgrade-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Countdown = require('../common/countdown');
const expectedRecvData = 'nurtzo';

// Create a TCP server
const srv = net.createServer(function(c) {
const server = net.createServer(function(c) {
c.on('data', function(d) {
c.write('HTTP/1.1 101\r\n');
c.write('hello: world\r\n');
Expand All @@ -49,7 +49,7 @@ const srv = net.createServer(function(c) {
});
});

srv.listen(0, '127.0.0.1', common.mustCall(function() {
server.listen(0, '127.0.0.1', common.mustCall(function() {
const port = this.address().port;
const headers = [
{
Expand All @@ -63,7 +63,7 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() {
['Origin', 'http://www.websocket.org']
]
];
const countdown = new Countdown(headers.length, () => srv.close());
const countdown = new Countdown(headers.length, () => server.close());

headers.forEach(function(h) {
const req = http.get({
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-net-error-twice.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ function ready() {
}
}

const srv = net.createServer(function onConnection(conn) {
const server = net.createServer(function onConnection(conn) {
conn.on('error', function(err) {
errs.push(err);
if (errs.length > 1 && errs[0] === errs[1])
assert.fail('Should not emit the same error twice');
});
conn.on('close', function() {
srv.unref();
server.unref();
});
serverSocket = conn;
ready();
Expand Down
12 changes: 6 additions & 6 deletions test/parallel/test-net-server-listen-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function randomPipePath() {
{
const handlePath = randomPipePath();

const srv = net.createServer()
const server = net.createServer()
.listen({
path: handlePath,
readableAll: true,
Expand All @@ -66,24 +66,24 @@ function randomPipePath() {
assert.notStrictEqual(mode & fs.constants.S_IROTH, 0);
assert.notStrictEqual(mode & fs.constants.S_IWOTH, 0);
}
srv.close();
server.close();
}));
}

// Test should emit "error" events when listening fails.
{
const handlePath = randomPipePath();
const srv1 = net.createServer().listen({ path: handlePath }, () => {
const server1 = net.createServer().listen({ path: handlePath }, () => {
// As the handlePath is in use, binding to the same address again should
// make the server emit an 'EADDRINUSE' error.
const srv2 = net.createServer()
const server2 = net.createServer()
.listen({
path: handlePath,
writableAll: true,
}, common.mustNotCall());

srv2.on('error', common.mustCall((err) => {
srv1.close();
server2.on('error', common.mustCall((err) => {
server1.close();
assert.strictEqual(err.code, 'EADDRINUSE');
assert(/^listen EADDRINUSE: address already in use/.test(err.message));
}));
Expand Down

0 comments on commit d76deca

Please sign in to comment.