mirror of
https://github.com/knex/knex.git
synced 2025-12-27 06:58:39 +00:00
* Fix `#listAllAndCompleted` not considering `loadExtensions` in migrator configuration (#2998) * Add unit test * Fix linting
This commit is contained in:
parent
fcd21d9bf3
commit
0aacab50be
@ -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",
|
||||
|
||||
@ -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),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -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']);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user