add env folder for boot

This commit is contained in:
yorkie 2015-09-25 13:25:34 +08:00
parent d1b00ce5d8
commit d249b15ce0
6 changed files with 42 additions and 0 deletions

View File

@ -71,6 +71,8 @@ module.exports = function compile(options) {
bootDirs.forEach(function(dir) {
bootScripts = bootScripts.concat(findScripts(dir));
var envdir = dir + '/' + env;
bootScripts = bootScripts.concat(findScripts(envdir));
});
// de-dedup boot scripts -ERS

View File

@ -11,6 +11,7 @@ var supertest = require('supertest');
var os = require('os');
var SIMPLE_APP = path.join(__dirname, 'fixtures', 'simple-app');
var ENV_APP = path.join(__dirname, 'fixtures', 'env-app');
var app;
@ -754,6 +755,19 @@ describe('executor', function() {
.get('/')
.expect('passport', 'initialized', done);
});
describe('when booting with env', function() {
it('should set the `booting` flag during execution', function(done) {
expect(app.booting).to.be.undefined();
boot.execute(app, envAppInstructions(), function(err) {
if (err) return done(err);
expect(app.booting).to.be.false();
expect(process.bootFlags).to.not.have.property('barLoadedInTest');
done();
});
});
});
});
function simpleMiddlewareConfig(phase, params) {
@ -826,3 +840,11 @@ function simpleAppInstructions() {
fs.copySync(SIMPLE_APP, appdir.PATH);
return boot.compile(appdir.PATH);
}
function envAppInstructions() {
fs.copySync(ENV_APP, appdir.PATH);
return boot.compile({
appRootDir: appdir.PATH,
env: 'test'
});
}

View File

@ -0,0 +1,4 @@
process.bootFlags.push('barLoadedInTest');
module.exports = function(app, callback) {
callback();
};

4
test/fixtures/env-app/config.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"port": 3000,
"host": "127.0.0.1"
}

View File

@ -0,0 +1,5 @@
{
"db": {
"connector": "memory"
}
}

View File

@ -0,0 +1,5 @@
{
"User": {
"dataSource": "db"
}
}