From e2cee5be669bfee0e2485327f41ad3ce140b4712 Mon Sep 17 00:00:00 2001 From: Sebastian Gierlinger Date: Thu, 7 Nov 2013 14:26:47 +0100 Subject: [PATCH] Move API tests to /integration/ closes #1396 - moved core/test/unit/api* to core/test/integration/api/ - moved core/test/integration/model* to core/test/integration/model/ - moved core/test/unit/utils to core/test/utils - moved core/test/unit/fixtures to core/test/utils/fixtures/ - changed gruntfile.js to execute api tests with target 'integration' --- Gruntfile.js | 11 +++++++++-- core/test/{unit => integration/api}/api_posts_spec.js | 2 +- .../{unit => integration/api}/api_settings_spec.js | 2 +- core/test/{unit => integration/api}/api_tags_spec.js | 2 +- core/test/{unit => integration/api}/api_users_spec.js | 2 +- .../integration/{ => model}/model_permissions_spec.js | 6 +++--- core/test/integration/{ => model}/model_posts_spec.js | 4 ++-- core/test/integration/{ => model}/model_roles_spec.js | 6 +++--- .../integration/{ => model}/model_settings_spec.js | 6 +++--- core/test/integration/{ => model}/model_tags_spec.js | 4 ++-- core/test/integration/{ => model}/model_users_spec.js | 6 +++--- core/test/unit/client_ghostdown_spec.js | 2 +- core/test/unit/client_showdown_int_spec.js | 2 +- core/test/unit/errorHandling_spec.js | 2 +- core/test/unit/export_spec.js | 2 +- core/test/unit/ghost_spec.js | 6 +++--- core/test/unit/import_spec.js | 2 +- core/test/unit/mail_spec.js | 2 +- core/test/unit/permissions_spec.js | 2 +- core/test/unit/plugins_spec.js | 2 +- core/test/unit/server_helpers_index_spec.js | 2 +- core/test/unit/shared_gfm_spec.js | 2 +- core/test/{unit => }/utils/api.js | 0 core/test/{unit => utils}/fixtures/data-generator.js | 0 core/test/{unit => utils}/fixtures/test.hbs | 0 .../{unit => utils}/fixtures/theme/partials/test.hbs | 0 core/test/{unit => }/utils/index.js | 8 ++++---- 27 files changed, 46 insertions(+), 39 deletions(-) rename core/test/{unit => integration/api}/api_posts_spec.js (99%) rename core/test/{unit => integration/api}/api_settings_spec.js (99%) rename core/test/{unit => integration/api}/api_tags_spec.js (98%) rename core/test/{unit => integration/api}/api_users_spec.js (99%) rename core/test/integration/{ => model}/model_permissions_spec.js (94%) rename core/test/integration/{ => model}/model_posts_spec.js (99%) rename core/test/integration/{ => model}/model_roles_spec.js (94%) rename core/test/integration/{ => model}/model_settings_spec.js (97%) rename core/test/integration/{ => model}/model_tags_spec.js (99%) rename core/test/integration/{ => model}/model_users_spec.js (97%) rename core/test/{unit => }/utils/api.js (100%) rename core/test/{unit => utils}/fixtures/data-generator.js (100%) rename core/test/{unit => utils}/fixtures/test.hbs (100%) rename core/test/{unit => utils}/fixtures/theme/partials/test.hbs (100%) rename core/test/{unit => }/utils/index.js (88%) diff --git a/Gruntfile.js b/Gruntfile.js index 27ccbb2637..f209e714ea 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -200,7 +200,11 @@ var path = require('path'), }, api: { - src: ['core/test/unit/**/api*_spec.js'] + src: ['core/test/integration/**/api*_spec.js'] + }, + + model: { + src: ['core/test/integration/**/model*_spec.js'] }, client: { @@ -227,7 +231,10 @@ var path = require('path'), }, integration: { - src: ['core/test/integration/**/model*_spec.js'] + src: [ + 'core/test/integration/**/model*_spec.js', + 'core/test/integration/**/api*_spec.js' + ] } }, diff --git a/core/test/unit/api_posts_spec.js b/core/test/integration/api/api_posts_spec.js similarity index 99% rename from core/test/unit/api_posts_spec.js rename to core/test/integration/api/api_posts_spec.js index c54f49ed60..d399e315be 100644 --- a/core/test/unit/api_posts_spec.js +++ b/core/test/integration/api/api_posts_spec.js @@ -1,5 +1,5 @@ /*globals describe, before, beforeEach, afterEach, it */ -var testUtils = require('./utils'), +var testUtils = require('../../utils'), should = require('should'), _ = require('underscore'), request = require('request'), diff --git a/core/test/unit/api_settings_spec.js b/core/test/integration/api/api_settings_spec.js similarity index 99% rename from core/test/unit/api_settings_spec.js rename to core/test/integration/api/api_settings_spec.js index 172bc108a8..25b993ff1b 100644 --- a/core/test/unit/api_settings_spec.js +++ b/core/test/integration/api/api_settings_spec.js @@ -1,5 +1,5 @@ /*globals describe, before, beforeEach, afterEach, it */ -var testUtils = require('./utils'), +var testUtils = require('../../utils'), should = require('should'), _ = require('underscore'), request = require('request'), diff --git a/core/test/unit/api_tags_spec.js b/core/test/integration/api/api_tags_spec.js similarity index 98% rename from core/test/unit/api_tags_spec.js rename to core/test/integration/api/api_tags_spec.js index 5fedefec0b..bdbe5d4c45 100644 --- a/core/test/unit/api_tags_spec.js +++ b/core/test/integration/api/api_tags_spec.js @@ -1,5 +1,5 @@ /*globals describe, before, beforeEach, afterEach, it */ -var testUtils = require('./utils'), +var testUtils = require('../../utils'), should = require('should'), _ = require('underscore'), request = require('request'), diff --git a/core/test/unit/api_users_spec.js b/core/test/integration/api/api_users_spec.js similarity index 99% rename from core/test/unit/api_users_spec.js rename to core/test/integration/api/api_users_spec.js index b623d48e16..d4f93083e6 100644 --- a/core/test/unit/api_users_spec.js +++ b/core/test/integration/api/api_users_spec.js @@ -1,5 +1,5 @@ /*globals describe, before, beforeEach, afterEach, it */ -var testUtils = require('./utils'), +var testUtils = require('../../utils'), should = require('should'), _ = require('underscore'), request = require('request'), diff --git a/core/test/integration/model_permissions_spec.js b/core/test/integration/model/model_permissions_spec.js similarity index 94% rename from core/test/integration/model_permissions_spec.js rename to core/test/integration/model/model_permissions_spec.js index c7e602fb34..2c927b6e5b 100644 --- a/core/test/integration/model_permissions_spec.js +++ b/core/test/integration/model/model_permissions_spec.js @@ -1,10 +1,10 @@ /*globals describe, it, before, beforeEach, afterEach */ -var testUtils = require('../unit/utils'), +var testUtils = require('../../utils'), should = require('should'), - errors = require('../../server/errorHandling'), + errors = require('../../../server/errorHandling'), // Stuff we are testing - Models = require('../../server/models'); + Models = require('../../../server/models'); describe("Permission Model", function () { diff --git a/core/test/integration/model_posts_spec.js b/core/test/integration/model/model_posts_spec.js similarity index 99% rename from core/test/integration/model_posts_spec.js rename to core/test/integration/model/model_posts_spec.js index 365ef018bf..9ab6c2be2a 100644 --- a/core/test/integration/model_posts_spec.js +++ b/core/test/integration/model/model_posts_spec.js @@ -1,12 +1,12 @@ /*globals describe, before, beforeEach, afterEach, it */ -var testUtils = require('../unit/utils'), +var testUtils = require('../../utils'), should = require('should'), _ = require('underscore'), when = require('when'), sequence = require('when/sequence'), // Stuff we are testing - Models = require('../../server/models'); + Models = require('../../../server/models'); describe('Post Model', function () { diff --git a/core/test/integration/model_roles_spec.js b/core/test/integration/model/model_roles_spec.js similarity index 94% rename from core/test/integration/model_roles_spec.js rename to core/test/integration/model/model_roles_spec.js index 68e3081bc4..dc21ddddf1 100644 --- a/core/test/integration/model_roles_spec.js +++ b/core/test/integration/model/model_roles_spec.js @@ -1,10 +1,10 @@ /*globals describe, it, before, beforeEach, afterEach */ -var testUtils = require('../unit/utils'), +var testUtils = require('../../utils'), should = require('should'), - errors = require('../../server/errorHandling'), + errors = require('../../../server/errorHandling'), // Stuff we are testing - Models = require('../../server/models'); + Models = require('../../../server/models'); describe("Role Model", function () { diff --git a/core/test/integration/model_settings_spec.js b/core/test/integration/model/model_settings_spec.js similarity index 97% rename from core/test/integration/model_settings_spec.js rename to core/test/integration/model/model_settings_spec.js index 4bd2a41be9..7ed9640501 100644 --- a/core/test/integration/model_settings_spec.js +++ b/core/test/integration/model/model_settings_spec.js @@ -1,11 +1,11 @@ /*globals describe, before, beforeEach, afterEach, it*/ -var testUtils = require('../unit/utils'), +var testUtils = require('../../utils'), should = require('should'), _ = require("underscore"), // Stuff we are testing - Models = require('../../server/models'), - knex = require('../../server/models/base').knex; + Models = require('../../../server/models'), + knex = require('../../../server/models/base').knex; describe('Settings Model', function () { diff --git a/core/test/integration/model_tags_spec.js b/core/test/integration/model/model_tags_spec.js similarity index 99% rename from core/test/integration/model_tags_spec.js rename to core/test/integration/model/model_tags_spec.js index b85ade3d85..359825eddb 100644 --- a/core/test/integration/model_tags_spec.js +++ b/core/test/integration/model/model_tags_spec.js @@ -1,12 +1,12 @@ /*globals describe, before, beforeEach, afterEach, it */ -var testUtils = require('../unit/utils'), +var testUtils = require('../../utils'), _ = require("underscore"), when = require('when'), sequence = require('when/sequence'), should = require('should'), // Stuff we are testing - Models = require('../../server/models'); + Models = require('../../../server/models'); describe('Tag Model', function () { diff --git a/core/test/integration/model_users_spec.js b/core/test/integration/model/model_users_spec.js similarity index 97% rename from core/test/integration/model_users_spec.js rename to core/test/integration/model/model_users_spec.js index fe37dd86de..f2573a7166 100644 --- a/core/test/integration/model_users_spec.js +++ b/core/test/integration/model/model_users_spec.js @@ -1,12 +1,12 @@ /*globals describe, before, beforeEach, afterEach, it*/ -var testUtils = require('../unit/utils'), +var testUtils = require('../../utils'), should = require('should'), when = require('when'), _ = require('underscore'), - errors = require('../../server/errorHandling'), + errors = require('../../../server/errorHandling'), // Stuff we are testing - Models = require('../../server/models'); + Models = require('../../../server/models'); describe('User Model', function run() { diff --git a/core/test/unit/client_ghostdown_spec.js b/core/test/unit/client_ghostdown_spec.js index e9a2beb560..2558d51822 100644 --- a/core/test/unit/client_ghostdown_spec.js +++ b/core/test/unit/client_ghostdown_spec.js @@ -6,7 +6,7 @@ */ /*globals describe, it */ -var testUtils = require('./utils'), +var testUtils = require('../utils'), should = require('should'), // Stuff we are testing diff --git a/core/test/unit/client_showdown_int_spec.js b/core/test/unit/client_showdown_int_spec.js index 9e0c13c37d..e715536c78 100644 --- a/core/test/unit/client_showdown_int_spec.js +++ b/core/test/unit/client_showdown_int_spec.js @@ -5,7 +5,7 @@ */ /*globals describe, it */ -var testUtils = require('./utils'), +var testUtils = require('../utils'), should = require('should'), // Stuff we are testing diff --git a/core/test/unit/errorHandling_spec.js b/core/test/unit/errorHandling_spec.js index 081f05e1e1..d844db5429 100644 --- a/core/test/unit/errorHandling_spec.js +++ b/core/test/unit/errorHandling_spec.js @@ -1,5 +1,5 @@ /*globals describe, beforeEach, it*/ -var testUtils = require('./utils'), +var testUtils = require('../utils'), should = require('should'), when = require('when'), sinon = require('sinon'), diff --git a/core/test/unit/export_spec.js b/core/test/unit/export_spec.js index fe1087dd19..7631c53788 100644 --- a/core/test/unit/export_spec.js +++ b/core/test/unit/export_spec.js @@ -1,5 +1,5 @@ /*globals describe, before, beforeEach, afterEach, it*/ -var testUtils = require('./utils'), +var testUtils = require('../utils'), should = require('should'), sinon = require('sinon'), when = require('when'), diff --git a/core/test/unit/ghost_spec.js b/core/test/unit/ghost_spec.js index fcc7e4ed3d..e5ea44bf69 100644 --- a/core/test/unit/ghost_spec.js +++ b/core/test/unit/ghost_spec.js @@ -1,5 +1,5 @@ /*globals describe, before, beforeEach, it*/ -var testUtils = require('./utils'), +var testUtils = require('../utils'), should = require('should'), sinon = require('sinon'), when = require('when'), @@ -10,8 +10,8 @@ var testUtils = require('./utils'), Ghost = require('../../ghost'); describe("Ghost API", function () { - var testTemplatePath = 'core/test/unit/fixtures/', - themeTemplatePath = 'core/test/unit/fixtures/theme', + var testTemplatePath = 'core/test/utils/fixtures/', + themeTemplatePath = 'core/test/utils/fixtures/theme', sandbox, ghost; diff --git a/core/test/unit/import_spec.js b/core/test/unit/import_spec.js index b88e8948d2..5e12ed1949 100644 --- a/core/test/unit/import_spec.js +++ b/core/test/unit/import_spec.js @@ -1,5 +1,5 @@ /*globals describe, beforeEach, it*/ -var testUtils = require('./utils'), +var testUtils = require('../utils'), should = require('should'), sinon = require('sinon'), when = require('when'), diff --git a/core/test/unit/mail_spec.js b/core/test/unit/mail_spec.js index 256bba3b8e..0611cbb0c5 100644 --- a/core/test/unit/mail_spec.js +++ b/core/test/unit/mail_spec.js @@ -1,5 +1,5 @@ /*globals describe, beforeEach, afterEach, it*/ -var testUtils = require('./utils'), +var testUtils = require('../utils'), should = require('should'), sinon = require('sinon'), when = require('when'), diff --git a/core/test/unit/permissions_spec.js b/core/test/unit/permissions_spec.js index 0aef8c8925..1e47242fee 100644 --- a/core/test/unit/permissions_spec.js +++ b/core/test/unit/permissions_spec.js @@ -1,5 +1,5 @@ /*globals describe, before, beforeEach, afterEach, it*/ -var testUtils = require('./utils'), +var testUtils = require('../utils'), should = require('should'), sinon = require('sinon'), when = require('when'), diff --git a/core/test/unit/plugins_spec.js b/core/test/unit/plugins_spec.js index 72f2c1e2bb..977d4796c4 100644 --- a/core/test/unit/plugins_spec.js +++ b/core/test/unit/plugins_spec.js @@ -1,5 +1,5 @@ /*globals describe, beforeEach, afterEach, before, it*/ -var testUtils = require('./utils'), +var testUtils = require('../utils'), should = require('should'), sinon = require('sinon'), _ = require("underscore"), diff --git a/core/test/unit/server_helpers_index_spec.js b/core/test/unit/server_helpers_index_spec.js index 527c2b76e2..908f687eba 100644 --- a/core/test/unit/server_helpers_index_spec.js +++ b/core/test/unit/server_helpers_index_spec.js @@ -1,5 +1,5 @@ /*globals describe, beforeEach, it*/ -var testUtils = require('./utils'), +var testUtils = require('../utils'), should = require('should'), sinon = require('sinon'), when = require('when'), diff --git a/core/test/unit/shared_gfm_spec.js b/core/test/unit/shared_gfm_spec.js index 3afe70cba9..9ec46eda6d 100644 --- a/core/test/unit/shared_gfm_spec.js +++ b/core/test/unit/shared_gfm_spec.js @@ -4,7 +4,7 @@ */ /*globals describe, it */ -var testUtils = require('./utils'), +var testUtils = require('../utils'), should = require('should'), // Stuff we are testing diff --git a/core/test/unit/utils/api.js b/core/test/utils/api.js similarity index 100% rename from core/test/unit/utils/api.js rename to core/test/utils/api.js diff --git a/core/test/unit/fixtures/data-generator.js b/core/test/utils/fixtures/data-generator.js similarity index 100% rename from core/test/unit/fixtures/data-generator.js rename to core/test/utils/fixtures/data-generator.js diff --git a/core/test/unit/fixtures/test.hbs b/core/test/utils/fixtures/test.hbs similarity index 100% rename from core/test/unit/fixtures/test.hbs rename to core/test/utils/fixtures/test.hbs diff --git a/core/test/unit/fixtures/theme/partials/test.hbs b/core/test/utils/fixtures/theme/partials/test.hbs similarity index 100% rename from core/test/unit/fixtures/theme/partials/test.hbs rename to core/test/utils/fixtures/theme/partials/test.hbs diff --git a/core/test/unit/utils/index.js b/core/test/utils/index.js similarity index 88% rename from core/test/unit/utils/index.js rename to core/test/utils/index.js index 86f4c3d843..bd385702b1 100644 --- a/core/test/unit/utils/index.js +++ b/core/test/utils/index.js @@ -1,8 +1,8 @@ -var knex = require('../../../server/models/base').knex, +var knex = require('../../server/models/base').knex, when = require('when'), - migration = require("../../../server/data/migration/"), - Settings = require('../../../server/models/settings').Settings, - DataGenerator = require('../fixtures/data-generator'), + migration = require("../../server/data/migration/"), + Settings = require('../../server/models/settings').Settings, + DataGenerator = require('./fixtures/data-generator'), API = require('./api'); function initData() {