This commit is contained in:
arnaucode
2017-02-03 08:56:51 +01:00
parent c4b7414770
commit 112745d6fa
1585 changed files with 450241 additions and 0 deletions

0
www/node_modules/portfinder/test/fixtures/.gitkeep generated vendored Normal file
View File

View File

@@ -0,0 +1,67 @@
/*
* portfinder-test.js: Tests for the `portfinder` module.
*
* (C) 2011, Charlie Robbins
*
*/
var vows = require('vows'),
assert = require('assert'),
async = require('async'),
http = require('http'),
portfinder = require('../lib/portfinder');
var servers = [];
function createServers (callback) {
var base = 8000;
async.whilst(
function () { return base < 8005 },
function (next) {
var server = http.createServer(function () { });
server.listen(base, next);
base++;
servers.push(server);
}, callback);
}
vows.describe('portfinder').addBatch({
"When using portfinder module": {
"with 5 existing servers": {
topic: function () {
createServers(this.callback);
},
"the getPorts() method with an argument of 3": {
topic: function () {
portfinder.getPorts(3, this.callback);
},
"should respond with the first three available ports (8005, 8006, 8007)": function (err, ports) {
assert.isTrue(!err);
assert.deepEqual(ports, [8005, 8006, 8007]);
}
}
}
}
}).addBatch({
"When using portfinder module": {
"with no existing servers": {
topic: function () {
servers.forEach(function (server) {
server.close();
});
return null;
},
"the getPorts() method with an argument of 3": {
topic: function () {
portfinder.getPorts(3, this.callback);
},
"should respond with the first three available ports (8000, 8001, 80072": function (err, ports) {
assert.isTrue(!err);
assert.deepEqual(ports, [8000, 8001, 8002]);
}
}
}
}
}).export(module);

View File

@@ -0,0 +1,92 @@
/*
* portfinder-test.js: Tests for the `portfinder` module.
*
* (C) 2011, Charlie Robbins
*
*/
var assert = require('assert'),
exec = require('child_process').exec,
net = require('net'),
path = require('path'),
async = require('async'),
vows = require('vows'),
portfinder = require('../lib/portfinder');
var servers = [],
socketDir = path.join(__dirname, 'fixtures'),
badDir = path.join(__dirname, 'bad-dir');
function createServers (callback) {
var base = 0;
async.whilst(
function () { return base < 5 },
function (next) {
var server = net.createServer(function () { }),
name = base === 0 ? 'test.sock' : 'test' + base + '.sock';
server.listen(path.join(socketDir, name), next);
base++;
servers.push(server);
}, callback);
}
vows.describe('portfinder').addBatch({
"When using portfinder module": {
"with 5 existing servers": {
topic: function () {
createServers(this.callback);
},
"the getPort() method": {
topic: function () {
portfinder.getSocket({
path: path.join(socketDir, 'test.sock')
}, this.callback);
},
"should respond with the first free socket (test5.sock)": function (err, socket) {
assert.isTrue(!err);
assert.equal(socket, path.join(socketDir, 'test5.sock'));
}
}
}
}
}).addBatch({
"When using portfinder module": {
"with no existing servers": {
"the getSocket() method": {
"with a directory that doesnt exist": {
topic: function () {
var that = this;
exec('rm -rf ' + badDir, function () {
portfinder.getSocket({
path: path.join(badDir, 'test.sock')
}, that.callback);
});
},
"should respond with the first free socket (test.sock)": function (err, socket) {
assert.isTrue(!err);
assert.equal(socket, path.join(badDir, 'test.sock'));
}
},
"with a directory that exists": {
topic: function () {
portfinder.getSocket({
path: path.join(socketDir, 'exists.sock')
}, this.callback);
},
"should respond with the first free socket (exists.sock)": function (err, socket) {
assert.isTrue(!err);
assert.equal(socket, path.join(socketDir, 'exists.sock'));
}
}
}
}
}
}).addBatch({
"When the tests are over": {
"necessary cleanup should take place": function () {
exec('rm -rf ' + badDir + ' ' + path.join(socketDir, '*'), function () { });
}
}
}).export(module);

67
www/node_modules/portfinder/test/port-finder-test.js generated vendored Normal file
View File

@@ -0,0 +1,67 @@
/*
* portfinder-test.js: Tests for the `portfinder` module.
*
* (C) 2011, Charlie Robbins
*
*/
var vows = require('vows'),
assert = require('assert'),
async = require('async'),
http = require('http'),
portfinder = require('../lib/portfinder');
var servers = [];
function createServers (callback) {
var base = 8000;
async.whilst(
function () { return base < 8005 },
function (next) {
var server = http.createServer(function () { });
server.listen(base, next);
base++;
servers.push(server);
}, callback);
}
vows.describe('portfinder').addBatch({
"When using portfinder module": {
"with 5 existing servers": {
topic: function () {
createServers(this.callback);
},
"the getPort() method": {
topic: function () {
portfinder.getPort(this.callback);
},
"should respond with the first free port (8005)": function (err, port) {
assert.isTrue(!err);
assert.equal(port, 8005);
}
}
}
}
}).addBatch({
"When using portfinder module": {
"with no existing servers": {
topic: function () {
servers.forEach(function (server) {
server.close();
});
return null;
},
"the getPort() method": {
topic: function () {
portfinder.getPort(this.callback);
},
"should respond with the first free port (8000)": function (err, port) {
assert.isTrue(!err);
assert.equal(port, 8000);
}
}
}
}
}).export(module);