Skip to content

Commit

Permalink
Fix for #2998 - Migrator & TypeScript (#3041)
Browse files Browse the repository at this point in the history
* Fix `#listAllAndCompleted` not considering `loadExtensions` in migrator configuration (#2998)

* Add unit test

* Fix linting
  • Loading branch information
pvoisin authored and kibertoad committed Mar 9, 2019
1 parent fcd21d9 commit 0aacab5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/migrate/migration-list-resolver.js
Expand Up @@ -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),
]);
}
21 changes: 21 additions & 0 deletions test/unit/migrate/migration-list-resolver.js
Expand Up @@ -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')
Expand Down Expand Up @@ -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']);
});
});
});
});

0 comments on commit 0aacab5

Please sign in to comment.