2020-04-29 18:44:27 +03:00
|
|
|
const should = require('should');
|
|
|
|
const sinon = require('sinon');
|
|
|
|
const testUtils = require('../../utils');
|
|
|
|
const _ = require('lodash');
|
2013-09-15 20:04:42 +04:00
|
|
|
|
2020-04-29 18:44:27 +03:00
|
|
|
// Stuff we are testing
|
|
|
|
const exporter = require('../../../core/server/data/exporter');
|
|
|
|
|
|
|
|
const ghostVersion = require('../../../core/server/lib/ghost-version');
|
2013-09-15 20:04:42 +04:00
|
|
|
|
2014-06-05 01:26:03 +04:00
|
|
|
describe('Exporter', function () {
|
2020-02-24 23:51:09 +03:00
|
|
|
before(testUtils.teardownDb);
|
|
|
|
afterEach(testUtils.teardownDb);
|
2014-07-21 21:50:04 +04:00
|
|
|
afterEach(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2013-09-15 20:04:42 +04:00
|
|
|
});
|
2016-07-15 19:22:41 +03:00
|
|
|
beforeEach(testUtils.setup('default', 'settings'));
|
2014-07-21 21:50:04 +04:00
|
|
|
|
|
|
|
should.exist(exporter);
|
2013-09-15 20:04:42 +04:00
|
|
|
|
2014-06-05 01:26:03 +04:00
|
|
|
it('exports data', function (done) {
|
2016-03-12 21:54:06 +03:00
|
|
|
exporter.doExport().then(function (exportData) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const tables = ['posts', 'users', 'roles', 'roles_users', 'permissions', 'permissions_roles',
|
2017-01-26 15:12:00 +03:00
|
|
|
'permissions_users', 'settings', 'tags', 'posts_tags'];
|
2013-09-15 20:04:42 +04:00
|
|
|
|
|
|
|
should.exist(exportData);
|
|
|
|
|
|
|
|
should.exist(exportData.meta);
|
|
|
|
should.exist(exportData.data);
|
|
|
|
|
2017-12-14 16:13:40 +03:00
|
|
|
exportData.meta.version.should.equal(ghostVersion.full);
|
2013-09-15 20:04:42 +04:00
|
|
|
|
|
|
|
_.each(tables, function (name) {
|
|
|
|
should.exist(exportData.data[name]);
|
|
|
|
});
|
2017-01-26 15:12:00 +03:00
|
|
|
|
2018-08-06 18:18:59 +03:00
|
|
|
should.not.exist(_.find(exportData.data.settings, {key: 'permalinks'}));
|
|
|
|
|
2013-09-15 20:04:42 +04:00
|
|
|
// should not export sqlite data
|
|
|
|
should.not.exist(exportData.data.sqlite_sequence);
|
|
|
|
done();
|
2014-05-06 00:58:58 +04:00
|
|
|
}).catch(done);
|
2013-09-15 20:04:42 +04:00
|
|
|
});
|
|
|
|
});
|