Fix for #2998 - Migrator & TypeScript (#3041)

* Fix `#listAllAndCompleted` not considering `loadExtensions` in migrator configuration (#2998)

* Add unit test

* Fix linting
This commit is contained in:
Pierre Voisin 2019-03-09 17:39:55 -05:00 committed by Igor Savin
parent fcd21d9bf3
commit 0aacab50be
3 changed files with 23 additions and 2 deletions

View File

@ -62,7 +62,7 @@
"pg-query-stream": "^2.0.0",
"prettier": "^1.16.2",
"rimraf": "^2.6.3",
"sinon": "^7.2.3",
"sinon": "^7.2.7",
"sinon-chai": "^3.3.0",
"source-map-support": "^0.5.10",
"sqlite3": "^4.0.6",

View File

@ -28,7 +28,7 @@ export function listCompleted(tableName, schemaName, trxOrKnex) {
// the list of completed migrations to check what should be run.
export function listAllAndCompleted(config, trxOrKnex) {
return Promise.all([
listAll(config.migrationSource),
listAll(config.migrationSource, config.loadExtensions),
listCompleted(config.tableName, config.schemaName, trxOrKnex),
]);
}

View File

@ -2,7 +2,9 @@
/*eslint no-var:0, indent:0, max-len:0 */
'use strict';
const Promise = require('bluebird');
const { expect } = require('chai');
const sinon = require('sinon');
const mockFs = require('mock-fs');
const migrationListResolver = require('../../../lib/migrate/migration-list-resolver');
const FsMigrations = require('../../../lib/migrate/sources/fs-migrations')
@ -186,4 +188,23 @@ describe('migration-list-resolver', () => {
});
});
});
describe('listAllAndCompleted', () => {
it('should pass loadExtensions param to listAll', () => {
after(() => {
sinon.restore();
});
const migrationSource = new FsMigrations([], true);
const stub = sinon
.stub(migrationSource, 'getMigrations')
.callsFake(() => Promise.resolve(true));
return migrationListResolver
.listAll(migrationSource, ['.ts'])
.then(() => {
sinon.assert.calledWith(stub, ['.ts']);
});
});
});
});