From 3d42a3338f4c3df692f2cd70b4b57fd259e93db6 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Tue, 29 Oct 2013 20:54:37 +0000 Subject: [PATCH 1/2] Run tests on MySQL and SQLite3. fixes #921 --- .travis.yml | 6 +++++- Gruntfile.js | 2 +- config.example.js | 22 +++++++++++++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 693db1d0f5..0ed022b4fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,9 @@ language: node_js node_js: - "0.10" +env: + - DB=sqlite3 + - DB=mysql git: submodules: false before_install: @@ -12,7 +15,8 @@ before_install: - git checkout tags/1.1-beta1 - export PATH=$PATH:`pwd`/bin - cd - + - if [ $DB == "mysql" ]; then mysql -e 'create database ghost_travis'; fi before_script: - phantomjs --version - casperjs --version - - grunt init \ No newline at end of file + - grunt init diff --git a/Gruntfile.js b/Gruntfile.js index 423d6b3795..d299219e6b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -498,7 +498,7 @@ var path = require('path'), grunt.initConfig(cfg); 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' : 'testing'; + process.env.NODE_ENV = process.env.TRAVIS ? 'travis-' + process.env.DB : 'testing'; }); grunt.registerTask('loadConfig', function () { diff --git a/config.example.js b/config.example.js index 8ac22f8569..621875590f 100644 --- a/config.example.js +++ b/config.example.js @@ -82,7 +82,7 @@ config = { // ### Travis // Automated testing run through GitHub - travis: { + 'travis-sqlite3': { url: 'http://127.0.0.1:2368', database: { client: 'sqlite3', @@ -94,6 +94,26 @@ config = { host: '127.0.0.1', port: '2368' } + }, + + // ### Travis + // Automated testing run through GitHub + 'travis-mysql': { + url: 'http://127.0.0.1:2368', + database: { + client: 'mysql', + connection: { + host : '127.0.0.1', + user : 'travis', + password : '', + database : 'ghost-travis', + charset : 'utf8' + } + }, + server: { + host: '127.0.0.1', + port: '2368' + } } }; From 933a8c764a2abf1dbb999791e13dedcecb861318 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Tue, 29 Oct 2013 21:34:47 +0000 Subject: [PATCH 2/2] Separate model tests to separate tasks/directory. refs #921 --- Gruntfile.js | 8 +++++++- core/test/{unit => integration}/model_permissions_spec.js | 4 ++-- core/test/{unit => integration}/model_posts_spec.js | 2 +- core/test/{unit => integration}/model_roles_spec.js | 4 ++-- core/test/{unit => integration}/model_settings_spec.js | 2 +- core/test/{unit => integration}/model_tags_spec.js | 2 +- core/test/{unit => integration}/model_users_spec.js | 4 ++-- 7 files changed, 16 insertions(+), 10 deletions(-) rename core/test/{unit => integration}/model_permissions_spec.js (98%) rename core/test/{unit => integration}/model_posts_spec.js (99%) rename core/test/{unit => integration}/model_roles_spec.js (98%) rename core/test/{unit => integration}/model_settings_spec.js (99%) rename core/test/{unit => integration}/model_tags_spec.js (99%) rename core/test/{unit => integration}/model_users_spec.js (98%) diff --git a/Gruntfile.js b/Gruntfile.js index d299219e6b..a9351d09ab 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -237,6 +237,10 @@ var path = require('path'), 'core/test/unit/**/export_spec.js', 'core/test/unit/**/import_spec.js' ] + }, + + integration: { + src: ['core/test/integration/**/model*_spec.js'] } }, @@ -865,9 +869,11 @@ var path = require('path'), grunt.registerTask('test-unit', 'Run unit tests', ['clean:test', 'setTestEnv', 'loadConfig', 'express:test', 'mochacli:all']); + grunt.registerTask('test-integration', 'Run integration tests', ['clean:test', 'setTestEnv', 'loadConfig', 'express:test', 'mochacli:integration']); + grunt.registerTask('test-functional', 'Run casperjs tests only', ['clean:test', 'setTestEnv', 'express:test', 'spawn-casperjs']); - grunt.registerTask('validate', 'Run tests and lint code', ['jslint', 'test-unit', 'test-functional']); + grunt.registerTask('validate', 'Run tests and lint code', ['jslint', 'test-unit', 'test-integration', 'test-functional']); grunt.registerTask('docs', 'Generate Docs', ['groc']); diff --git a/core/test/unit/model_permissions_spec.js b/core/test/integration/model_permissions_spec.js similarity index 98% rename from core/test/unit/model_permissions_spec.js rename to core/test/integration/model_permissions_spec.js index 547ba42bb3..4ea303a46c 100644 --- a/core/test/unit/model_permissions_spec.js +++ b/core/test/integration/model_permissions_spec.js @@ -1,5 +1,5 @@ /*globals describe, it, before, beforeEach, afterEach */ -var testUtils = require('./testUtils'), +var testUtils = require('../unit/testUtils'), should = require('should'), errors = require('../../server/errorHandling'), @@ -97,4 +97,4 @@ describe("Permission Model", function () { done(); }).then(null, done); }); -}); \ No newline at end of file +}); diff --git a/core/test/unit/model_posts_spec.js b/core/test/integration/model_posts_spec.js similarity index 99% rename from core/test/unit/model_posts_spec.js rename to core/test/integration/model_posts_spec.js index 28b50493f7..1d6ccb643b 100644 --- a/core/test/unit/model_posts_spec.js +++ b/core/test/integration/model_posts_spec.js @@ -1,5 +1,5 @@ /*globals describe, before, beforeEach, afterEach, it */ -var testUtils = require('./testUtils'), +var testUtils = require('../unit/testUtils'), should = require('should'), _ = require('underscore'), when = require('when'), diff --git a/core/test/unit/model_roles_spec.js b/core/test/integration/model_roles_spec.js similarity index 98% rename from core/test/unit/model_roles_spec.js rename to core/test/integration/model_roles_spec.js index 38db598c97..d525ebb63d 100644 --- a/core/test/unit/model_roles_spec.js +++ b/core/test/integration/model_roles_spec.js @@ -1,5 +1,5 @@ /*globals describe, it, before, beforeEach, afterEach */ -var testUtils = require('./testUtils'), +var testUtils = require('../unit/testUtils'), should = require('should'), errors = require('../../server/errorHandling'), @@ -97,4 +97,4 @@ describe("Role Model", function () { done(); }).then(null, done); }); -}); \ No newline at end of file +}); diff --git a/core/test/unit/model_settings_spec.js b/core/test/integration/model_settings_spec.js similarity index 99% rename from core/test/unit/model_settings_spec.js rename to core/test/integration/model_settings_spec.js index e87722b0b2..cf1b0d30ab 100644 --- a/core/test/unit/model_settings_spec.js +++ b/core/test/integration/model_settings_spec.js @@ -1,5 +1,5 @@ /*globals describe, before, beforeEach, afterEach, it*/ -var testUtils = require('./testUtils'), +var testUtils = require('../unit/testUtils'), should = require('should'), _ = require("underscore"), diff --git a/core/test/unit/model_tags_spec.js b/core/test/integration/model_tags_spec.js similarity index 99% rename from core/test/unit/model_tags_spec.js rename to core/test/integration/model_tags_spec.js index 00dade6316..70c4b9d15d 100644 --- a/core/test/unit/model_tags_spec.js +++ b/core/test/integration/model_tags_spec.js @@ -1,5 +1,5 @@ /*globals describe, before, beforeEach, afterEach, it */ -var testUtils = require('./testUtils'), +var testUtils = require('../unit/testUtils'), _ = require("underscore"), when = require('when'), sequence = require('when/sequence'), diff --git a/core/test/unit/model_users_spec.js b/core/test/integration/model_users_spec.js similarity index 98% rename from core/test/unit/model_users_spec.js rename to core/test/integration/model_users_spec.js index 63fd9496a7..fb35ceeaf6 100644 --- a/core/test/unit/model_users_spec.js +++ b/core/test/integration/model_users_spec.js @@ -1,5 +1,5 @@ /*globals describe, before, beforeEach, afterEach, it*/ -var testUtils = require('./testUtils'), +var testUtils = require('../unit/testUtils'), should = require('should'), when = require('when'), _ = require('underscore'), @@ -174,4 +174,4 @@ describe('User Model', function run() { }); }); -}); \ No newline at end of file +});