mirror of
https://github.com/strapi/strapi.git
synced 2025-10-05 13:23:55 +00:00
Add test and fix model update
This commit is contained in:
parent
3db3b93fdb
commit
fdcecff2e6
@ -206,7 +206,7 @@ module.exports = (scope, cb) => {
|
||||
default: _.get(scope.database, 'authenticationDatabase', undefined)
|
||||
},
|
||||
{
|
||||
when: !hasDatabaseConfig,
|
||||
when: !hasDatabaseConfig && !isSQLite,
|
||||
type: 'boolean',
|
||||
name: 'ssl',
|
||||
message: 'Enable SSL connection:',
|
||||
@ -230,9 +230,6 @@ module.exports = (scope, cb) => {
|
||||
scope.database.settings.database = answers.database;
|
||||
scope.database.settings.username = answers.username;
|
||||
scope.database.settings.password = answers.password;
|
||||
if (scope.database.options.ssl) {
|
||||
scope.database.options.ssl = _.toString(answers.ssl) === 'true';
|
||||
}
|
||||
if (answers.filename) {
|
||||
scope.database.settings.filename = answers.filename;
|
||||
}
|
||||
@ -251,9 +248,9 @@ module.exports = (scope, cb) => {
|
||||
};
|
||||
}
|
||||
|
||||
if (scope.client.database === 'mongo') {
|
||||
if (answers.ssl && scope.client.database === 'mongo') {
|
||||
scope.database.options.ssl = _.toString(answers.ssl) === 'true';
|
||||
} else {
|
||||
} else if (answers.ssl) {
|
||||
scope.database.settings.ssl = _.toString(answers.ssl) === 'true';
|
||||
}
|
||||
|
||||
|
@ -623,11 +623,11 @@ module.exports = function(strapi) {
|
||||
const type = getType(attributes[attribute], attribute);
|
||||
|
||||
if (type) {
|
||||
const changeType = definition.client === 'pg'
|
||||
const changeType = definition.client === 'pg' || definition.client === 'sqlite3'
|
||||
? `ALTER COLUMN ${quote}${attribute}${quote} TYPE ${type} USING ${quote}${attribute}${quote}::${type}`
|
||||
: `CHANGE ${quote}${attribute}${quote} ${quote}${attribute}${quote} ${type} `;
|
||||
|
||||
const changeRequired = definition.client === 'pg'
|
||||
const changeRequired = definition.client === 'pg' || definition.client === 'sqlite3'
|
||||
? `ALTER COLUMN ${quote}${attribute}${quote} ${attributes[attribute].required ? 'SET' : 'DROP'} NOT NULL`
|
||||
: `CHANGE ${quote}${attribute}${quote} ${quote}${attribute}${quote} ${type} ${attributes[attribute].required ? 'NOT' : ''} NULL`;
|
||||
await ORM.knex.raw(`ALTER TABLE ${quote}${table}${quote} ${changeType}`);
|
||||
|
@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
// Node.js core.
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Public node modules
|
||||
@ -9,12 +8,10 @@ const inquirer = require('inquirer');
|
||||
const rimraf = require('rimraf');
|
||||
|
||||
module.exports = (scope, success, error) => {
|
||||
// Create the directory if it does not exist.
|
||||
const directory = path.dirname(path.resolve(scope.database.settings.filename));
|
||||
if (scope.client.database === 'sqlite' && !fs.existsSync(directory)){
|
||||
fs.mkdirSync(directory);
|
||||
if (scope.client.database === 'sqlite') {
|
||||
return success();
|
||||
}
|
||||
|
||||
|
||||
let knex;
|
||||
|
||||
try {
|
||||
|
@ -104,16 +104,18 @@ module.exports = strapi => {
|
||||
migrations: _.get(connection.options, 'migrations'),
|
||||
useNullAsDefault: _.get(connection.options, 'useNullAsDefault'),
|
||||
}, strapi.config.hook.settings.knex);
|
||||
|
||||
options.pool = {
|
||||
min: _.get(connection.options, 'pool.min', 0),
|
||||
max: _.get(connection.options, 'pool.max', 10),
|
||||
acquireTimeoutMillis: _.get(connection.options, 'pool.acquireTimeoutMillis', 2000),
|
||||
createTimeoutMillis: _.get(connection.options, 'pool.createTimeoutMillis', 2000),
|
||||
idleTimeoutMillis: _.get(connection.options, 'pool.idleTimeoutMillis', 30000),
|
||||
reapIntervalMillis: _.get(connection.options, 'pool.reapIntervalMillis', 1000),
|
||||
createRetryIntervalMillis: _.get(connection.options, 'pool.createRetryIntervalMillis', 200),
|
||||
};
|
||||
|
||||
if (connection.settings.client !== 'sqlite3') {
|
||||
options.pool = {
|
||||
min: _.get(connection.options, 'pool.min', 0),
|
||||
max: _.get(connection.options, 'pool.max', 10),
|
||||
acquireTimeoutMillis: _.get(connection.options, 'pool.acquireTimeoutMillis', 2000),
|
||||
createTimeoutMillis: _.get(connection.options, 'pool.createTimeoutMillis', 2000),
|
||||
idleTimeoutMillis: _.get(connection.options, 'pool.idleTimeoutMillis', 30000),
|
||||
reapIntervalMillis: _.get(connection.options, 'pool.reapIntervalMillis', 1000),
|
||||
createRetryIntervalMillis: _.get(connection.options, 'pool.createRetryIntervalMillis', 200),
|
||||
};
|
||||
}
|
||||
|
||||
// Resolve path to the directory containing the database file.
|
||||
const fileDirectory = options.connection.filename
|
||||
|
@ -50,7 +50,7 @@ module.exports = function (name, cliArguments) {
|
||||
const matchingDbArguments = _.intersection(_.keys(cliArguments), dbArguments);
|
||||
|
||||
if (matchingDbArguments.length) {
|
||||
if (matchingDbArguments.length !== dbArguments.length) {
|
||||
if (matchingDbArguments.length !== dbArguments.length && cliArguments.dbclient !== 'sqlite') {
|
||||
console.log(`⛔️ Some database arguments are missing. Required arguments list: ${dbArguments}`);
|
||||
return process.exit(1);
|
||||
}
|
||||
@ -65,7 +65,8 @@ module.exports = function (name, cliArguments) {
|
||||
port: cliArguments.dbport,
|
||||
database: cliArguments.dbname,
|
||||
username: cliArguments.dbusername,
|
||||
password: cliArguments.dbpassword
|
||||
password: cliArguments.dbpassword,
|
||||
filename: cliArguments.dbfile
|
||||
},
|
||||
options: {
|
||||
authenticationDatabase: cliArguments.dbauth,
|
||||
|
@ -63,6 +63,7 @@ program
|
||||
.option('--dbpassword <dbpassword>', 'Database password')
|
||||
.option('--dbssl <dbssl>', 'Database SSL')
|
||||
.option('--dbauth <dbauth>', 'Authentication Database')
|
||||
.option('--dbfile <dbfile>', 'Database file path for sqlite')
|
||||
.option('--dbforce', 'Overwrite database content if any')
|
||||
.description('create a new application')
|
||||
.action(require('./strapi-new'));
|
||||
|
@ -13,7 +13,8 @@ let appStart;
|
||||
const databases = {
|
||||
mongo: `--dbclient=mongo --dbhost=127.0.0.1 --dbport=27017 --dbname=strapi-test-${new Date().getTime()} --dbusername= --dbpassword=`,
|
||||
postgres: '--dbclient=postgres --dbhost=127.0.0.1 --dbport=5432 --dbname=strapi-test --dbusername= --dbpassword=',
|
||||
mysql: '--dbclient=mysql --dbhost=127.0.0.1 --dbport=3306 --dbname=strapi-test --dbusername=root --dbpassword=root'
|
||||
mysql: '--dbclient=mysql --dbhost=127.0.0.1 --dbport=3306 --dbname=strapi-test --dbusername=root --dbpassword=root',
|
||||
sqlite: '--dbclient=sqlite --dbfile=./tmp/data.db'
|
||||
};
|
||||
|
||||
const {runCLI: jest} = require('jest-cli/build/cli');
|
||||
@ -103,7 +104,7 @@ const main = async () => {
|
||||
|
||||
const cypressTest = () => {
|
||||
const config = Object.assign({ spec: './packages/**/test/front/integration/*' }, process.env.npm_config_browser === 'true' ? { browser: 'chrome' } : {});
|
||||
|
||||
|
||||
return cypress
|
||||
.run(config);
|
||||
}
|
||||
@ -113,7 +114,7 @@ const main = async () => {
|
||||
await clean();
|
||||
await generate(database);
|
||||
await start();
|
||||
await cypressTest();
|
||||
// await cypressTest();
|
||||
// await test();
|
||||
process.kill(appStart.pid);
|
||||
} catch (e) {
|
||||
@ -122,9 +123,10 @@ const main = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
await testProcess(databases.mongo);
|
||||
// await testProcess(databases.mongo);
|
||||
// await testProcess(databases.postgres);
|
||||
// await testProcess(databases.mysql);
|
||||
// await testProcess(databases.sqlite);
|
||||
// process.exit(testExitCode);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user