Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit 871261e

Browse files
committed
INT-958 add dryrun subcommand
The "dryrun" command invokes mongodb-version-manger but skips actual start/stop. This is useful on CI systems to ensure that a version of mongodb is available before mocha is invoked. Specify "mongodb-runner dryrun" as the "pretest" script.
1 parent 5b7cf0f commit 871261e

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

lib/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ function configure(opts, done) {
354354
var exec = module.exports = exports = function(opts, done) {
355355
opts.action = opts.action || 'start';
356356

357-
if (['start', 'stop'].indexOf(opts.action) === -1) {
357+
if (['dryrun', 'start', 'stop'].indexOf(opts.action) === -1) {
358358
done(new Error('Unknown action.'));
359359
return;
360360
}
@@ -371,6 +371,11 @@ var exec = module.exports = exports = function(opts, done) {
371371
return;
372372
}
373373

374+
if (opts.action === 'dryrun') {
375+
done();
376+
return;
377+
}
378+
374379
if (opts.action === 'start') {
375380
start(opts, done);
376381
}

test/index.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,37 @@
22

33
var run = require('../');
44
var kill = require('kill-mongodb');
5+
var mvm = require('mongodb-version-manager');
6+
var assert = require('assert');
57

68
describe('Test Spawning MongoDB Deployments', function() {
79
before(function(done) {
810
kill(done);
911
});
1012

13+
describe('Dry Run', function() {
14+
var opts = {
15+
action: 'dryrun',
16+
name: 'mongodb-runner-test-standalone',
17+
port: 20000
18+
};
19+
20+
it('should only invoke mongodb-version-manager', function(done) {
21+
run(opts, function(err) {
22+
if (err) {
23+
return done(err);
24+
}
25+
mvm.current(function(err2, v) {
26+
if (err2) {
27+
return done(err2);
28+
}
29+
assert(v); // ensure not null
30+
done();
31+
});
32+
});
33+
});
34+
});
35+
1136
describe('Standalone', function() {
1237
var opts = {
1338
action: 'start',

usage.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Usage: mongodb-runner <start|stop> [options]
1+
2+
Usage: mongodb-runner <start|stop|dryrun> [options]
23

34
Start/stop mongodb for testing.
45

0 commit comments

Comments
 (0)