2018-06-02 22:48:23 +03:00
|
|
|
var should = require('should'),
|
2017-12-14 05:36:50 +03:00
|
|
|
sinon = require('sinon'),
|
|
|
|
_ = require('lodash'),
|
|
|
|
fs = require('fs-extra'),
|
2020-03-30 18:26:47 +03:00
|
|
|
models = require('../../../../core/server/models'),
|
|
|
|
exporter = require('../../../../core/server/data/exporter'),
|
|
|
|
dbBackup = require('../../../../core/server/data/db/backup');
|
2017-12-14 05:36:50 +03:00
|
|
|
|
|
|
|
describe('Backup', function () {
|
|
|
|
var exportStub, filenameStub, fsStub;
|
|
|
|
|
|
|
|
before(function () {
|
|
|
|
models.init();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2017-12-14 05:36:50 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
exportStub = sinon.stub(exporter, 'doExport').resolves();
|
|
|
|
filenameStub = sinon.stub(exporter, 'fileName').resolves('test');
|
|
|
|
fsStub = sinon.stub(fs, 'writeFile').resolves();
|
2017-12-14 05:36:50 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should create a backup JSON file', function (done) {
|
2020-02-13 07:53:44 +03:00
|
|
|
dbBackup.backup().then(function () {
|
2017-12-14 05:36:50 +03:00
|
|
|
exportStub.calledOnce.should.be.true();
|
|
|
|
filenameStub.calledOnce.should.be.true();
|
|
|
|
fsStub.calledOnce.should.be.true();
|
|
|
|
|
|
|
|
done();
|
|
|
|
}).catch(done);
|
|
|
|
});
|
|
|
|
});
|