0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/test/unit/server/data/schema/commands.test.js
Sam Lord 2887e416da
Switch to @tryghost/errors from ignition errors package (#13807)
refs: TryGhost/Toolbox#147

* Replaces all references to isIgnitionError with isGhostError
* Switches use of GhostError to InternalServerError - as GhostError is no longer public
There are places where InternalServerError is not the valid error, and new errors should be added to the @tryghost/errors package to ensure that we can use semantically correct errors in those cases.
2021-12-01 10:22:01 +00:00

36 lines
1.2 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(errors.utils.isGhostError(err), 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(errors.utils.isGhostError(err), true);
err.message.should.equal('Must use hasPrimaryKeySQLite on an SQLite3 database');
}
});
});