Run tests on MySQL and use travis-$DB environments.

refs #921
fixes #1385
This commit is contained in:
Fabian Becker 2013-11-03 14:12:09 +00:00
parent c2ab917075
commit 0908ecf6b7
4 changed files with 16 additions and 26 deletions

View File

@ -482,6 +482,7 @@ var path = require('path'),
grunt.registerTask('setTestEnv', 'Use "testing" Ghost config; unless we are running on travis (then show queries for debugging)', function () {
process.env.NODE_ENV = process.env.TRAVIS ? 'travis-' + process.env.DB : 'testing';
cfg.express.test.options.node_env = process.env.NODE_ENV;
});
grunt.registerTask('loadConfig', function () {
@ -881,4 +882,4 @@ var path = require('path'),
grunt.registerTask('default', 'Build CSS, JS & templates for development', ['update_submodules', 'sass:compress', 'handlebars', 'concat']);
};
module.exports = configureGrunt;
module.exports = configureGrunt;

View File

@ -83,7 +83,7 @@ config = {
// ### Travis
// Automated testing run through GitHub
'travis-sqlite3': {
url: 'http://127.0.0.1:2368',
url: 'http://127.0.0.1:2369',
database: {
client: 'sqlite3',
connection: {
@ -92,27 +92,27 @@ config = {
},
server: {
host: '127.0.0.1',
port: '2368'
port: '2369'
}
},
// ### Travis
// Automated testing run through GitHub
'travis-mysql': {
url: 'http://127.0.0.1:2368',
url: 'http://127.0.0.1:2369',
database: {
client: 'mysql',
connection: {
host : '127.0.0.1',
user : 'travis',
password : '',
database : 'ghost-travis',
database : 'ghost_travis',
charset : 'utf8'
}
},
server: {
host: '127.0.0.1',
port: '2368'
port: '2369'
}
}
};

View File

@ -430,7 +430,7 @@ when(ghost.init()).then(function () {
});
} else {
console.log(
"Ghost is running...".green,
("Ghost is running in " + process.env.NODE_ENV + "...").green,
"\nListening on",
getSocket() || ghost.config().server.host + ':' + ghost.config().server.port,
"\nUrl configured as:",

View File

@ -15,22 +15,14 @@ function clearData() {
}
function insertDefaultFixtures() {
var promises = [];
promises.push(insertDefaultUser());
promises.push(insertPosts());
return when.all(promises);
return when(insertDefaultUser()
.then(insertPosts()));
}
function insertPosts() {
var promises = [];
promises.push(knex('posts').insert(DataGenerator.forKnex.posts));
promises.push(knex('tags').insert(DataGenerator.forKnex.tags));
promises.push(knex('posts_tags').insert(DataGenerator.forKnex.posts_tags));
return when.all(promises);
return when(knex('posts').insert(DataGenerator.forKnex.posts)
.then(knex('tags').insert(DataGenerator.forKnex.tags)
.then(knex('posts_tags').insert(DataGenerator.forKnex.posts_tags))));
}
function insertMorePosts() {
@ -58,15 +50,12 @@ function insertMorePosts() {
function insertDefaultUser() {
var users = [],
userRoles = [],
u_promises = [];
userRoles = [];
users.push(DataGenerator.forKnex.createUser(DataGenerator.Content.users[0]));
u_promises.push(knex('users').insert(users));
userRoles.push(DataGenerator.forKnex.createUserRole(1, 1));
u_promises.push(knex('roles_users').insert(userRoles));
return when.all(u_promises);
return when(knex('users').insert(users))
.then(knex('roles_users').insert(userRoles));
}
module.exports = {