|
|
@ -50,11 +50,19 @@ describe('Migrator', () => { |
|
|
|
const migrator = new Migrator({ migrations: liveMigrations }) |
|
|
|
const migrator = new Migrator({ migrations: liveMigrations }) |
|
|
|
migrator.migrateData(firstTimeState) |
|
|
|
migrator.migrateData(firstTimeState) |
|
|
|
.then((migratedData) => { |
|
|
|
.then((migratedData) => { |
|
|
|
console.log(migratedData) |
|
|
|
|
|
|
|
const last = liveMigrations.length - 1 |
|
|
|
const last = liveMigrations.length - 1 |
|
|
|
assert.equal(migratedData.meta.version, liveMigrations[last].version) |
|
|
|
assert.equal(migratedData.meta.version, liveMigrations[last].version) |
|
|
|
done() |
|
|
|
done() |
|
|
|
}).catch(done) |
|
|
|
}).catch(done) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should emit an error', function (done) { |
|
|
|
|
|
|
|
this.timeout(15000) |
|
|
|
|
|
|
|
const migrator = new Migrator({ migrations: [{ version: 1, migrate: async () => { throw new Error('test') } } ] }) |
|
|
|
|
|
|
|
migrator.on('error', () => done()) |
|
|
|
|
|
|
|
migrator.migrateData({ meta: {version: 0} }) |
|
|
|
|
|
|
|
.then((migratedData) => { |
|
|
|
|
|
|
|
}).catch(done) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|