mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-02 07:43:11 +03:00
Added exporter fields integrity check
refs https://github.com/TryGhost/Team/issues/610 - When either schema or default settings changes it's often forgotten to check if exporter handles updated tables/keys properly - These tests are meant to serve as a reminder to check exporter and modify what's needed when changes are introduced into schema/default settings
This commit is contained in:
parent
459e8215b9
commit
5680c93b83
@ -164,4 +164,34 @@ describe('Exporter', function () {
|
||||
}).catch(done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Export table whitelists', function () {
|
||||
it('should be fixed when db schema introduces new tables', function () {
|
||||
const {
|
||||
BACKUP_TABLES,
|
||||
TABLES_ALLOWLIST
|
||||
} = require('../../../../core/server/data/exporter/table-lists.js');
|
||||
|
||||
const nonSchemaTables = ['migrations', 'migrations_lock'];
|
||||
|
||||
// NOTE: this test is serving a role of a reminder to have a look into exported tables allowlists
|
||||
// if it failed you probably need to add or remove a table entry from table-lists module
|
||||
[...Object.keys(schema.tables), ...nonSchemaTables].sort().should.eql([...BACKUP_TABLES, ...TABLES_ALLOWLIST].sort());
|
||||
});
|
||||
|
||||
it('should be fixed when default settings is changed', function () {
|
||||
const {
|
||||
SETTING_KEYS_BLOCKLIST
|
||||
} = require('../../../../core/server/data/exporter/table-lists.js');
|
||||
const defaultSettings = require('../../../../core/server/data/schema/default-settings.json');
|
||||
|
||||
const totalKeysLength = Object.keys(defaultSettings).reduce((acc, curr, index) => {
|
||||
return acc + Object.keys(defaultSettings[curr]).length;
|
||||
}, 0);
|
||||
|
||||
// NOTE: if default settings changed either modify the settings keys blocklist or increase allowedKeysLength
|
||||
const allowedKeysLength = 76;
|
||||
totalKeysLength.should.eql(SETTING_KEYS_BLOCKLIST.length + allowedKeysLength);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user