mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-05 09:50:34 +03:00
810b052e01
refs2f1123d6ca
refs6f1a3e1774
- As per refed commits, we are removing deprecated use of `new Error()` in the codebase - Exposed few internal from commands module methods for easier testing, otherwise it was turning into neverending mocking show
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
const should = require('should');
|
|
const errors = require('@tryghost/errors');
|
|
|
|
const commands = require('../../../../core/server/data/schema/commands');
|
|
|
|
describe('schema commands', function () {
|
|
it('_hasForeignSQLite throws when knex is nox configured to use sqlite3', async function () {
|
|
const Knex = require('knex');
|
|
const knex = Knex({
|
|
client: 'mysql'
|
|
});
|
|
|
|
try {
|
|
await commands._hasForeignSQLite({transaction: knex});
|
|
should.fail('addForeign did not throw');
|
|
} catch (err) {
|
|
should.equal(err instanceof errors.GhostError, true);
|
|
err.message.should.equal('Must use hasForeignSQLite3 on an SQLite3 database');
|
|
}
|
|
});
|
|
|
|
it('_hasPrimaryKeySQLite throws when knex is configured to use sqlite', async function () {
|
|
const Knex = require('knex');
|
|
const knex = Knex({
|
|
client: 'mysql'
|
|
});
|
|
|
|
try {
|
|
await commands._hasPrimaryKeySQLite(null, knex);
|
|
should.fail('hasPrimaryKeySQLite did not throw');
|
|
} catch (err) {
|
|
should.equal(err instanceof errors.GhostError, true);
|
|
err.message.should.equal('Must use hasPrimaryKeySQLite on an SQLite3 database');
|
|
}
|
|
});
|
|
});
|