0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00
ghost/core/test/integration/export_spec.js

59 lines
1.9 KiB
JavaScript
Raw Normal View History

/*globals describe, before, beforeEach, afterEach, it*/
2014-06-04 16:26:03 -05:00
/*jshint expr:true*/
var testUtils = require('../utils/index'),
2014-06-04 16:26:03 -05:00
should = require('should'),
sinon = require('sinon'),
Promise = require('bluebird'),
2014-06-04 16:26:03 -05:00
_ = require('lodash'),
// Stuff we are testing
versioning = require('../../server/data/versioning/index'),
exporter = require('../../server/data/export/index'),
sandbox = sinon.sandbox.create();
2014-06-04 16:26:03 -05:00
describe('Exporter', function () {
before(testUtils.teardown);
afterEach(testUtils.teardown);
afterEach(function () {
sandbox.restore();
});
beforeEach(testUtils.setup('default'));
should.exist(exporter);
2014-06-04 16:26:03 -05:00
it('exports data', function (done) {
// Stub migrations to return 000 as the current database version
2014-06-04 16:26:03 -05:00
var versioningStub = sandbox.stub(versioning, 'getDatabaseVersion', function () {
return Promise.resolve('003');
});
exporter().then(function (exportData) {
2014-06-04 16:26:03 -05:00
var tables = ['posts', 'users', 'roles', 'roles_users', 'permissions', 'permissions_roles',
'permissions_users', 'settings', 'tags', 'posts_tags'],
dbVersionSetting;
should.exist(exportData);
should.exist(exportData.meta);
should.exist(exportData.data);
2014-06-04 16:26:03 -05:00
exportData.meta.version.should.equal('003');
dbVersionSetting = _.findWhere(exportData.data.settings, {key: 'databaseVersion'});
should.exist(dbVersionSetting);
dbVersionSetting.value.should.equal('003');
_.each(tables, function (name) {
should.exist(exportData.data[name]);
});
// should not export sqlite data
should.not.exist(exportData.data.sqlite_sequence);
versioningStub.restore();
done();
}).catch(done);
});
});