mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Initial commit of 005 version
refs #6301 - bump the default version & update corresponding test - add empty task folders for 005 data & fixture migrations - update tests to cover the new 005 upgrades
This commit is contained in:
parent
31ebc7f3dd
commit
fa8555bda2
5 changed files with 112 additions and 7 deletions
3
core/server/data/migration/005/index.js
Normal file
3
core/server/data/migration/005/index.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
module.exports = [
|
||||
// Nothing to do yet
|
||||
];
|
3
core/server/data/migration/fixtures/005/index.js
Normal file
3
core/server/data/migration/fixtures/005/index.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
module.exports = [
|
||||
// Nothing to do yet
|
||||
];
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"core": {
|
||||
"databaseVersion": {
|
||||
"defaultValue": "004"
|
||||
"defaultValue": "005"
|
||||
},
|
||||
"dbHash": {
|
||||
"defaultValue": null
|
||||
|
|
|
@ -12,6 +12,7 @@ var should = require('should'),
|
|||
update = rewire('../../server/data/migration/fixtures/update'),
|
||||
populate = rewire('../../server/data/migration/fixtures/populate'),
|
||||
fixtures004 = require('../../server/data/migration/fixtures/004'),
|
||||
fixtures005 = require('../../server/data/migration/fixtures/005'),
|
||||
ensureDefaultSettings = require('../../server/data/migration/fixtures/settings'),
|
||||
|
||||
sandbox = sinon.sandbox.create();
|
||||
|
@ -124,6 +125,11 @@ describe('Fixtures', function () {
|
|||
clientEditStub = sandbox.stub(models.Client, 'edit').returns(Promise.resolve());
|
||||
});
|
||||
|
||||
it('should have tasks for 004', function () {
|
||||
should.exist(fixtures004);
|
||||
fixtures004.should.be.an.Array().with.lengthOf(8);
|
||||
});
|
||||
|
||||
describe('01-move-jquery-with-alert', function () {
|
||||
it('tries to move jQuery to ghost_foot', function (done) {
|
||||
getObjStub.get.returns('');
|
||||
|
@ -685,6 +691,47 @@ describe('Fixtures', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Update to 005', function () {
|
||||
it('should call all the 005 fixture upgrades', function (done) {
|
||||
// Setup
|
||||
// Create a new stub, this will replace sequence, so that db calls don't actually get run
|
||||
var sequenceStub = sandbox.stub(),
|
||||
sequenceReset = update.__set__('sequence', sequenceStub);
|
||||
|
||||
// The first time we call sequence, it should be to execute a top level version, e.g 005
|
||||
// yieldsTo('0') means this stub will execute the function at index 0 of the array passed as the
|
||||
// first argument. In short the `runVersionTasks` function gets executed, and sequence gets called
|
||||
// again with the array of tasks to execute for 005, which is what we want to check
|
||||
|
||||
// Can't yield until we have at least one task
|
||||
// sequenceStub.onFirstCall().yieldsTo('0').returns(Promise.resolve([]));
|
||||
sequenceStub.returns(Promise.resolve([]));
|
||||
|
||||
update(['005'], loggerStub).then(function (result) {
|
||||
should.exist(result);
|
||||
|
||||
loggerStub.info.calledOnce.should.be.true();
|
||||
loggerStub.warn.called.should.be.false();
|
||||
|
||||
sequenceStub.calledOnce.should.be.true();
|
||||
|
||||
sequenceStub.firstCall.calledWith(sinon.match.array, sinon.match.object, loggerStub).should.be.true();
|
||||
sequenceStub.firstCall.args[0].should.be.an.Array().with.lengthOf(0);
|
||||
|
||||
// Reset
|
||||
sequenceReset();
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
describe('Tasks:', function () {
|
||||
it('should have tasks for 005', function () {
|
||||
should.exist(fixtures005);
|
||||
fixtures005.should.be.an.Array().with.lengthOf(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Populate fixtures', function () {
|
||||
|
|
|
@ -21,6 +21,7 @@ var should = require('should'),
|
|||
populate = require('../../server/data/migration/populate'),
|
||||
update = rewire('../../server/data/migration/update'),
|
||||
updates004 = require('../../server/data/migration/004'),
|
||||
updates005 = require('../../server/data/migration/005'),
|
||||
|
||||
defaultSettings = schema.defaultSettings,
|
||||
schemaTables = Object.keys(schema.tables),
|
||||
|
@ -33,7 +34,7 @@ var should = require('should'),
|
|||
// both of which are required for migrations to work properly.
|
||||
describe('DB version integrity', function () {
|
||||
// Only these variables should need updating
|
||||
var currentDbVersion = '004',
|
||||
var currentDbVersion = '005',
|
||||
currentSchemaHash = 'a195562bf4915e3f3f610f6d178aba01',
|
||||
currentFixturesHash = '77ebb081539f9e0c49f487faf7fd929e';
|
||||
|
||||
|
@ -343,7 +344,7 @@ describe('Migrations', function () {
|
|||
// yieldsTo('0') means this stub will execute the function at index 0 of the array passed as the
|
||||
// first argument. In short the `runVersionTasks` function gets executed, and sequence gets called
|
||||
// again with the array of tasks to execute for 004, which is what we want to check
|
||||
sequenceStub.onFirstCall().yieldsTo('0');
|
||||
sequenceStub.onFirstCall().yieldsTo('0').returns(Promise.resolve([]));
|
||||
|
||||
// Execute
|
||||
update('003', '004', loggerStub).then(function () {
|
||||
|
@ -359,14 +360,13 @@ describe('Migrations', function () {
|
|||
tasksSpy.firstCall.returnValue.should.be.an.Array().with.lengthOf(5);
|
||||
|
||||
sequenceStub.calledTwice.should.be.true();
|
||||
|
||||
sequenceStub.firstCall.calledWith(sinon.match.array, loggerStub).should.be.true();
|
||||
sequenceStub.secondCall.calledWith(sinon.match.array, loggerStub).should.be.true();
|
||||
|
||||
sequenceStub.firstCall.args[0].should.be.an.Array().with.lengthOf(1);
|
||||
sequenceStub.secondCall.args[0].should.be.an.Array().with.lengthOf(5);
|
||||
|
||||
sequenceStub.firstCall.args[0][0].should.be.a.Function().with.property('name', 'runVersionTasks');
|
||||
|
||||
sequenceStub.secondCall.calledWith(sinon.match.array, loggerStub).should.be.true();
|
||||
sequenceStub.secondCall.args[0].should.be.an.Array().with.lengthOf(5);
|
||||
sequenceStub.secondCall.args[0][0].should.be.a.Function().with.property('name', 'addTourColumnToUsers');
|
||||
sequenceStub.secondCall.args[0][1].should.be.a.Function().with.property('name', 'addSortOrderColumnToPostsTags');
|
||||
sequenceStub.secondCall.args[0][2].should.be.a.Function().with.property('name', 'addManyColumnsToClients');
|
||||
|
@ -402,6 +402,11 @@ describe('Migrations', function () {
|
|||
knexStub.restore();
|
||||
});
|
||||
|
||||
it('should have tasks for 004', function () {
|
||||
should.exist(updates004);
|
||||
updates004.should.be.an.Array().with.lengthOf(5);
|
||||
});
|
||||
|
||||
describe('01-add-tour-column-to-users', function () {
|
||||
it('does not try to add a new column if the table does not exist', function (done) {
|
||||
// Setup
|
||||
|
@ -771,6 +776,53 @@ describe('Migrations', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Update to 005', function () {
|
||||
it('should call all the 005 database upgrade tasks', function (done) {
|
||||
// Setup
|
||||
// Create a new stub, this will replace sequence, so that db calls don't actually get run
|
||||
var sequenceStub = sandbox.stub(),
|
||||
sequenceReset = update.__set__('sequence', sequenceStub);
|
||||
|
||||
// The first time we call sequence, it should be to execute a top level version, e.g 005
|
||||
// yieldsTo('0') means this stub will execute the function at index 0 of the array passed as the
|
||||
// first argument. In short the `runVersionTasks` function gets executed, and sequence gets called
|
||||
// again with the array of tasks to execute for 005, which is what we want to check
|
||||
|
||||
// Can't yield until we have at least one task
|
||||
// sequenceStub.onFirstCall().yieldsTo('0').returns(Promise.resolve([]));
|
||||
|
||||
// Execute
|
||||
update('004', '005', loggerStub).then(function () {
|
||||
errorStub.called.should.be.false();
|
||||
loggerStub.info.called.should.be.false();
|
||||
|
||||
versionsSpy.calledOnce.should.be.true();
|
||||
versionsSpy.calledWith('004', '005').should.be.true();
|
||||
versionsSpy.returned(['004', '005']).should.be.true();
|
||||
|
||||
tasksSpy.calledOnce.should.be.true();
|
||||
tasksSpy.calledWith('005', loggerStub).should.be.true();
|
||||
tasksSpy.firstCall.returnValue.should.be.an.Array().with.lengthOf(0);
|
||||
|
||||
sequenceStub.calledOnce.should.be.true();
|
||||
|
||||
sequenceStub.firstCall.calledWith(sinon.match.array, loggerStub).should.be.true();
|
||||
sequenceStub.firstCall.args[0].should.be.an.Array().with.lengthOf(0);
|
||||
|
||||
// Reset sequence
|
||||
sequenceReset();
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
describe('Tasks:', function () {
|
||||
it('should have tasks for 005', function () {
|
||||
should.exist(updates005);
|
||||
updates005.should.be.an.Array().with.lengthOf(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Update Database Schema', function () {
|
||||
|
|
Loading…
Reference in a new issue