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.createRestAppAndListen = createRestAppAndListen;
|
||||||
exports.getUserProperties = getUserProperties;
|
exports.getUserProperties = getUserProperties;
|
||||||
|
|
||||||
function createRestAppAndListen(port) {
|
function createRestAppAndListen() {
|
||||||
var app = loopback();
|
var app = loopback();
|
||||||
|
|
||||||
app.set('host', '127.0.0.1');
|
app.set('host', '127.0.0.1');
|
||||||
if (port) app.set('port', port);
|
app.set('port', 0);
|
||||||
|
|
||||||
app.use(loopback.rest());
|
app.use(loopback.rest());
|
||||||
app.locals.handler = app.listen();
|
app.locals.handler = app.listen();
|
||||||
|
|
|
@ -4,19 +4,24 @@ var helper = require('./helper');
|
||||||
describe('RemoteConnector', function() {
|
describe('RemoteConnector', function() {
|
||||||
var ctx = this;
|
var ctx = this;
|
||||||
|
|
||||||
before(function() {
|
before(function setupServer(done) {
|
||||||
ctx.serverApp = helper.createRestAppAndListen(3001);
|
ctx.serverApp = helper.createRestAppAndListen();
|
||||||
ctx.ServerModel = helper.createModel({
|
ctx.ServerModel = helper.createModel({
|
||||||
parent: 'TestModel',
|
parent: 'TestModel',
|
||||||
app: ctx.serverApp,
|
app: ctx.serverApp,
|
||||||
datasource: helper.createMemoryDataSource()
|
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({
|
ctx.RemoteModel = helper.createModel({
|
||||||
parent: 'TestModel',
|
parent: 'TestModel',
|
||||||
app: ctx.remoteApp,
|
app: ctx.remoteApp,
|
||||||
datasource: helper.createRemoteDataSource(ctx.serverApp)
|
datasource: helper.createRemoteDataSource(ctx.serverApp)
|
||||||
});
|
});
|
||||||
|
ctx.remoteApp.locals.handler.on('listening', function() { done(); });
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
|
@ -66,8 +71,8 @@ describe('RemoteConnector', function() {
|
||||||
describe('Custom Path', function() {
|
describe('Custom Path', function() {
|
||||||
var ctx = this;
|
var ctx = this;
|
||||||
|
|
||||||
before(function(done) {
|
before(function setupServer(done) {
|
||||||
ctx.serverApp = helper.createRestAppAndListen(3001);
|
ctx.serverApp = helper.createRestAppAndListen();
|
||||||
ctx.ServerModel = helper.createModel({
|
ctx.ServerModel = helper.createModel({
|
||||||
parent: 'TestModel',
|
parent: 'TestModel',
|
||||||
app: ctx.serverApp,
|
app: ctx.serverApp,
|
||||||
|
@ -76,8 +81,11 @@ describe('Custom Path', function() {
|
||||||
http: {path: '/custom'}
|
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({
|
ctx.RemoteModel = helper.createModel({
|
||||||
parent: 'TestModel',
|
parent: 'TestModel',
|
||||||
app: ctx.remoteApp,
|
app: ctx.remoteApp,
|
||||||
|
@ -87,7 +95,7 @@ describe('Custom Path', function() {
|
||||||
http: {path: '/custom'}
|
http: {path: '/custom'}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
done();
|
ctx.remoteApp.locals.handler.on('listening', function() { done(); });
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function(done)
|
after(function(done)
|
||||||
|
|
|
@ -5,22 +5,26 @@ var TaskEmitter = require('strong-task-emitter');
|
||||||
describe('Remote model tests', function() {
|
describe('Remote model tests', function() {
|
||||||
var ctx = this;
|
var ctx = this;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function(done) {
|
||||||
ctx.serverApp = helper.createRestAppAndListen(3001);
|
ctx.serverApp = helper.createRestAppAndListen();
|
||||||
ctx.ServerModel = helper.createModel({
|
ctx.ServerModel = helper.createModel({
|
||||||
parent: 'TestModel',
|
parent: 'TestModel',
|
||||||
app: ctx.serverApp,
|
app: ctx.serverApp,
|
||||||
datasource: helper.createMemoryDataSource(),
|
datasource: helper.createMemoryDataSource(),
|
||||||
properties: helper.userProperties
|
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({
|
ctx.RemoteModel = helper.createModel({
|
||||||
parent: 'TestModel',
|
parent: 'TestModel',
|
||||||
app: ctx.remoteApp,
|
app: ctx.remoteApp,
|
||||||
datasource: helper.createRemoteDataSource(ctx.serverApp),
|
datasource: helper.createRemoteDataSource(ctx.serverApp),
|
||||||
properties: helper.userProperties
|
properties: helper.userProperties
|
||||||
});
|
});
|
||||||
|
ctx.remoteApp.locals.handler.on('listening', function() { done(); });
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
|
|
Loading…
Reference in New Issue