mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 16:14:25 +03:00
fd0f5a5028
closes #2690 - added new error classes - moved errorhandling.js to /errors/index.js - changed API errors to use new classes - updated tests
69 lines
2.0 KiB
JavaScript
69 lines
2.0 KiB
JavaScript
/*globals describe, before, beforeEach, afterEach, it*/
|
|
var testUtils = require('../utils'),
|
|
should = require('should'),
|
|
sinon = require('sinon'),
|
|
when = require('when'),
|
|
_ = require("lodash"),
|
|
errors = require('../../server/errors'),
|
|
|
|
// Stuff we are testing
|
|
migration = require('../../server/data/migration'),
|
|
exporter = require('../../server/data/export'),
|
|
Settings = require('../../server/models/settings').Settings;
|
|
|
|
describe("Exporter", function () {
|
|
|
|
should.exist(exporter);
|
|
|
|
var sandbox;
|
|
|
|
before(function (done) {
|
|
testUtils.clearData().then(function () {
|
|
done();
|
|
}).catch(done);
|
|
});
|
|
|
|
beforeEach(function (done) {
|
|
sandbox = sinon.sandbox.create();
|
|
testUtils.initData().then(function () {
|
|
done();
|
|
}).catch(done);
|
|
});
|
|
|
|
afterEach(function (done) {
|
|
sandbox.restore();
|
|
testUtils.clearData().then(function () {
|
|
done();
|
|
}).catch(done);
|
|
});
|
|
|
|
it("exports data", function (done) {
|
|
// Stub migrations to return 000 as the current database version
|
|
var migrationStub = sandbox.stub(migration, "getDatabaseVersion", function () {
|
|
return when.resolve("003");
|
|
});
|
|
|
|
exporter().then(function (exportData) {
|
|
var tables = ['posts', 'users', 'roles', 'roles_users', 'permissions', 'permissions_roles', 'permissions_users',
|
|
'settings', 'tags', 'posts_tags'];
|
|
|
|
should.exist(exportData);
|
|
|
|
should.exist(exportData.meta);
|
|
should.exist(exportData.data);
|
|
|
|
exportData.meta.version.should.equal("003");
|
|
_.findWhere(exportData.data.settings, {key: "databaseVersion"}).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);
|
|
|
|
migrationStub.restore();
|
|
done();
|
|
}).catch(done);
|
|
});
|
|
});
|