mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
Fix slowdown of tests by reverting back to using knex in test/utils
This commit is contained in:
parent
cddd23f926
commit
25076ab087
@ -1,4 +1,4 @@
|
|||||||
var config = require('../../server/config'),
|
var knex = require('../../server/models/base').knex,
|
||||||
when = require('when'),
|
when = require('when'),
|
||||||
sequence = require('when/sequence'),
|
sequence = require('when/sequence'),
|
||||||
nodefn = require('when/node'),
|
nodefn = require('when/node'),
|
||||||
@ -20,7 +20,6 @@ function clearData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function insertPosts() {
|
function insertPosts() {
|
||||||
var knex = config().database.knex;
|
|
||||||
// ToDo: Get rid of pyramid of doom
|
// ToDo: Get rid of pyramid of doom
|
||||||
return when(knex('posts').insert(DataGenerator.forKnex.posts).then(function () {
|
return when(knex('posts').insert(DataGenerator.forKnex.posts).then(function () {
|
||||||
return knex('tags').insert(DataGenerator.forKnex.tags).then(function () {
|
return knex('tags').insert(DataGenerator.forKnex.tags).then(function () {
|
||||||
@ -47,18 +46,16 @@ function insertMorePosts(max) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sequence(_.times(posts.length, function (index) {
|
return sequence(_.times(posts.length, function(index) {
|
||||||
return function() {
|
return function() {
|
||||||
return config().database.knex('posts').insert(posts[index]);
|
return knex('posts').insert(posts[index]);
|
||||||
};
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertMorePostsTags(max) {
|
function insertMorePostsTags(max) {
|
||||||
max = max || 50;
|
max = max || 50;
|
||||||
|
|
||||||
var knex = config().database.knex;
|
|
||||||
|
|
||||||
return when.all([
|
return when.all([
|
||||||
// PostgreSQL can return results in any order
|
// PostgreSQL can return results in any order
|
||||||
knex('posts').orderBy('id', 'asc').select('id'),
|
knex('posts').orderBy('id', 'asc').select('id'),
|
||||||
@ -89,8 +86,7 @@ function insertMorePostsTags(max) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function insertDefaultUser() {
|
function insertDefaultUser() {
|
||||||
var user,
|
var user;
|
||||||
knex = config().database.knex;
|
|
||||||
|
|
||||||
user = DataGenerator.forKnex.createUser(DataGenerator.Content.users[0]);
|
user = DataGenerator.forKnex.createUser(DataGenerator.Content.users[0]);
|
||||||
|
|
||||||
@ -101,8 +97,7 @@ function insertDefaultUser() {
|
|||||||
|
|
||||||
function insertEditorUser() {
|
function insertEditorUser() {
|
||||||
var users = [],
|
var users = [],
|
||||||
userRoles = [],
|
userRoles = [];
|
||||||
knex = config().database.knex;
|
|
||||||
|
|
||||||
users.push(DataGenerator.forKnex.createUser(DataGenerator.Content.users[1]));
|
users.push(DataGenerator.forKnex.createUser(DataGenerator.Content.users[1]));
|
||||||
userRoles.push(DataGenerator.forKnex.createUserRole(2, 2));
|
userRoles.push(DataGenerator.forKnex.createUserRole(2, 2));
|
||||||
@ -115,8 +110,7 @@ function insertEditorUser() {
|
|||||||
|
|
||||||
function insertAuthorUser() {
|
function insertAuthorUser() {
|
||||||
var users = [],
|
var users = [],
|
||||||
userRoles = [],
|
userRoles = [];
|
||||||
knex = config().database.knex;
|
|
||||||
|
|
||||||
users.push(DataGenerator.forKnex.createUser(DataGenerator.Content.users[2]));
|
users.push(DataGenerator.forKnex.createUser(DataGenerator.Content.users[2]));
|
||||||
userRoles.push(DataGenerator.forKnex.createUserRole(3, 3));
|
userRoles.push(DataGenerator.forKnex.createUserRole(3, 3));
|
||||||
@ -128,8 +122,7 @@ function insertAuthorUser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function insertDefaultApp() {
|
function insertDefaultApp() {
|
||||||
var apps = [],
|
var apps = [];
|
||||||
knex = config().database.knex;
|
|
||||||
|
|
||||||
apps.push(DataGenerator.forKnex.createApp(DataGenerator.Content.apps[0]));
|
apps.push(DataGenerator.forKnex.createApp(DataGenerator.Content.apps[0]));
|
||||||
|
|
||||||
@ -145,16 +138,13 @@ function insertDefaultApp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function insertApps() {
|
function insertApps() {
|
||||||
var knex = config().database.knex;
|
|
||||||
return knex('apps').insert(DataGenerator.forKnex.apps).then(function () {
|
return knex('apps').insert(DataGenerator.forKnex.apps).then(function () {
|
||||||
return knex('app_fields').insert(DataGenerator.forKnex.app_fields);
|
return knex('app_fields').insert(DataGenerator.forKnex.app_fields);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertAppWithSettings() {
|
function insertAppWithSettings() {
|
||||||
var apps = [],
|
var apps = [], app_settings = [];
|
||||||
app_settings = [],
|
|
||||||
knex = config().database.knex;
|
|
||||||
|
|
||||||
apps.push(DataGenerator.forKnex.createApp(DataGenerator.Content.apps[0]));
|
apps.push(DataGenerator.forKnex.createApp(DataGenerator.Content.apps[0]));
|
||||||
app_settings.push(DataGenerator.forKnex.createAppSetting(DataGenerator.Content.app_settings[0]));
|
app_settings.push(DataGenerator.forKnex.createAppSetting(DataGenerator.Content.app_settings[0]));
|
||||||
@ -172,9 +162,7 @@ function insertAppWithSettings() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function insertAppWithFields() {
|
function insertAppWithFields() {
|
||||||
var apps = [],
|
var apps = [], app_fields = [];
|
||||||
app_fields = [],
|
|
||||||
knex = config().database.knex;
|
|
||||||
|
|
||||||
apps.push(DataGenerator.forKnex.createApp(DataGenerator.Content.apps[0]));
|
apps.push(DataGenerator.forKnex.createApp(DataGenerator.Content.apps[0]));
|
||||||
app_fields.push(DataGenerator.forKnex.createAppField(DataGenerator.Content.app_fields[0]));
|
app_fields.push(DataGenerator.forKnex.createAppField(DataGenerator.Content.app_fields[0]));
|
||||||
|
Loading…
Reference in New Issue
Block a user