Merge pull request #36 from strongloop/fix/ci
test: listen on ephemeral ports
This commit is contained in:
commit
74a2ce70ec
|
@ -7,11 +7,11 @@ exports.createRemoteDataSource = createRemoteDataSource;
|
|||
exports.createRestAppAndListen = createRestAppAndListen;
|
||||
exports.getUserProperties = getUserProperties;
|
||||
|
||||
function createRestAppAndListen(port) {
|
||||
function createRestAppAndListen() {
|
||||
var app = loopback();
|
||||
|
||||
app.set('host', '127.0.0.1');
|
||||
if (port) app.set('port', port);
|
||||
app.set('port', 0);
|
||||
|
||||
app.use(loopback.rest());
|
||||
app.locals.handler = app.listen();
|
||||
|
|
|
@ -4,19 +4,24 @@ var helper = require('./helper');
|
|||
describe('RemoteConnector', function() {
|
||||
var ctx = this;
|
||||
|
||||
before(function() {
|
||||
ctx.serverApp = helper.createRestAppAndListen(3001);
|
||||
before(function setupServer(done) {
|
||||
ctx.serverApp = helper.createRestAppAndListen();
|
||||
ctx.ServerModel = helper.createModel({
|
||||
parent: 'TestModel',
|
||||
app: ctx.serverApp,
|
||||
datasource: helper.createMemoryDataSource()
|
||||
});
|
||||
ctx.remoteApp = helper.createRestAppAndListen(3002);
|
||||
ctx.serverApp.locals.handler.on('listening', function() { done(); });
|
||||
});
|
||||
|
||||
before(function setupRemoteClient(done) {
|
||||
ctx.remoteApp = helper.createRestAppAndListen();
|
||||
ctx.RemoteModel = helper.createModel({
|
||||
parent: 'TestModel',
|
||||
app: ctx.remoteApp,
|
||||
datasource: helper.createRemoteDataSource(ctx.serverApp)
|
||||
});
|
||||
ctx.remoteApp.locals.handler.on('listening', function() { done(); });
|
||||
});
|
||||
|
||||
after(function() {
|
||||
|
@ -66,8 +71,8 @@ describe('RemoteConnector', function() {
|
|||
describe('Custom Path', function() {
|
||||
var ctx = this;
|
||||
|
||||
before(function(done) {
|
||||
ctx.serverApp = helper.createRestAppAndListen(3001);
|
||||
before(function setupServer(done) {
|
||||
ctx.serverApp = helper.createRestAppAndListen();
|
||||
ctx.ServerModel = helper.createModel({
|
||||
parent: 'TestModel',
|
||||
app: ctx.serverApp,
|
||||
|
@ -76,8 +81,11 @@ describe('Custom Path', function() {
|
|||
http: {path: '/custom'}
|
||||
}
|
||||
});
|
||||
ctx.serverApp.locals.handler.on('listening', function() { done(); });
|
||||
});
|
||||
|
||||
ctx.remoteApp = helper.createRestAppAndListen(3002);
|
||||
before(function setupRemoteClient(done) {
|
||||
ctx.remoteApp = helper.createRestAppAndListen();
|
||||
ctx.RemoteModel = helper.createModel({
|
||||
parent: 'TestModel',
|
||||
app: ctx.remoteApp,
|
||||
|
@ -87,7 +95,7 @@ describe('Custom Path', function() {
|
|||
http: {path: '/custom'}
|
||||
}
|
||||
});
|
||||
done();
|
||||
ctx.remoteApp.locals.handler.on('listening', function() { done(); });
|
||||
});
|
||||
|
||||
after(function(done)
|
||||
|
|
|
@ -5,22 +5,26 @@ var TaskEmitter = require('strong-task-emitter');
|
|||
describe('Remote model tests', function() {
|
||||
var ctx = this;
|
||||
|
||||
beforeEach(function() {
|
||||
ctx.serverApp = helper.createRestAppAndListen(3001);
|
||||
beforeEach(function(done) {
|
||||
ctx.serverApp = helper.createRestAppAndListen();
|
||||
ctx.ServerModel = helper.createModel({
|
||||
parent: 'TestModel',
|
||||
app: ctx.serverApp,
|
||||
datasource: helper.createMemoryDataSource(),
|
||||
properties: helper.userProperties
|
||||
});
|
||||
ctx.serverApp.locals.handler.on('listening', function() { done(); });
|
||||
});
|
||||
|
||||
ctx.remoteApp = helper.createRestAppAndListen(3002);
|
||||
beforeEach(function setupRemoteClient(done) {
|
||||
ctx.remoteApp = helper.createRestAppAndListen();
|
||||
ctx.RemoteModel = helper.createModel({
|
||||
parent: 'TestModel',
|
||||
app: ctx.remoteApp,
|
||||
datasource: helper.createRemoteDataSource(ctx.serverApp),
|
||||
properties: helper.userProperties
|
||||
});
|
||||
ctx.remoteApp.locals.handler.on('listening', function() { done(); });
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
|
|
Loading…
Reference in New Issue