Skip to content

Commit

Permalink
fix(check): fix check via API not passing results to the callback
Browse files Browse the repository at this point in the history
Signed-off-by: RandomSeeded <nate@blend.com>
  • Loading branch information
RandomSeeded committed Apr 16, 2018
1 parent 86669d5 commit b743696
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/commands/on-complete.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var assert = require('assert');
var log = require('db-migrate-shared').log;

module.exports = function (migrator, internals, callback, originalErr) {
module.exports = function (migrator, internals, callback, originalErr, results) {
if (typeof callback !== 'function') {
originalErr = originalErr || callback;
results = results || originalErr;
}

migrator.driver.close(function (err) {
Expand All @@ -22,7 +23,7 @@ module.exports = function (migrator, internals, callback, originalErr) {
}

if (typeof callback === 'function') {
callback();
callback(null, results);
}
});
};
27 changes: 27 additions & 0 deletions test/on_complete_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var Code = require('code');
var Lab = require('lab');
var lab = (exports.lab = Lab.script());
var onComplete = require('../lib/commands/on-complete');

lab.experiment('on-complete', function () {
lab.test('should invoke the callback with the results', function (done) {
var migratorMock = {
driver: {
close: function (cb) {
cb();
}
}
};
var internalsMock = {
argv: { }
};

var resultsPassedToCallback = 'callback should be invoked with results';
var testCallback = function (err, res) {
Code.expect(err).to.equal(null);
Code.expect(res).to.equal(resultsPassedToCallback);
done();
};
onComplete(migratorMock, internalsMock, testCallback, null, resultsPassedToCallback);
});
});

0 comments on commit b743696

Please sign in to comment.