Skip to content

Commit b743696

Browse files
author
RandomSeeded
committed
fix(check): fix check via API not passing results to the callback
Signed-off-by: RandomSeeded <[email protected]>
1 parent 86669d5 commit b743696

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

lib/commands/on-complete.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
var assert = require('assert');
22
var log = require('db-migrate-shared').log;
33

4-
module.exports = function (migrator, internals, callback, originalErr) {
4+
module.exports = function (migrator, internals, callback, originalErr, results) {
55
if (typeof callback !== 'function') {
66
originalErr = originalErr || callback;
7+
results = results || originalErr;
78
}
89

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

2425
if (typeof callback === 'function') {
25-
callback();
26+
callback(null, results);
2627
}
2728
});
2829
};

test/on_complete_test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var Code = require('code');
2+
var Lab = require('lab');
3+
var lab = (exports.lab = Lab.script());
4+
var onComplete = require('../lib/commands/on-complete');
5+
6+
lab.experiment('on-complete', function () {
7+
lab.test('should invoke the callback with the results', function (done) {
8+
var migratorMock = {
9+
driver: {
10+
close: function (cb) {
11+
cb();
12+
}
13+
}
14+
};
15+
var internalsMock = {
16+
argv: { }
17+
};
18+
19+
var resultsPassedToCallback = 'callback should be invoked with results';
20+
var testCallback = function (err, res) {
21+
Code.expect(err).to.equal(null);
22+
Code.expect(res).to.equal(resultsPassedToCallback);
23+
done();
24+
};
25+
onComplete(migratorMock, internalsMock, testCallback, null, resultsPassedToCallback);
26+
});
27+
});

0 commit comments

Comments
 (0)