Skip to content

Commit

Permalink
Merge f8f816a into 0278f19
Browse files Browse the repository at this point in the history
  • Loading branch information
todvora committed Oct 28, 2017
2 parents 0278f19 + f8f816a commit 88f37f7
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 61 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
sudo: false
node_js:
- "4"
- "5"
- "node"
- "lts/*"

after_script: "npm run coverage"
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environment:
matrix:
- nodejs_version: "4"
- nodejs_version: "5"
- nodejs_version: "LTS"
- nodejs_version: "Stable"
install:
- ps: Install-Product node $env:nodejs_version
- npm install -g jasmine-node
Expand Down
6 changes: 3 additions & 3 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = function(proc) {
.then(function(){return verifyVarietyLib(proc);})
.then(function(libPath){return executeVariety(proc, args, libPath);});
})
.catch(function(ex) {
return printHelp(proc, ex);
});
.catch(function(ex) {
return printHelp(proc, ex);
});
};
6 changes: 3 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ var jsVarDefinition = function(value, name) {

var buildParams = function(collection, opts) {
return _.map(
_.assign({}, {'collection':collection}, opts),
jsVarDefinition
).join('');
_.assign({}, {'collection':collection}, opts),
jsVarDefinition
).join('');
};

module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
"dependencies": {
"child-process-promise": "^2.0.1",
"colors": "^1.1.2",
"hjson": "^1.6.3",
"hjson": "^3.1.0",
"lodash": "^4.6.1",
"minimist": "^1.1.1",
"variety": "variety/variety"
},
"devDependencies": {
"coveralls": ">=2.11.2",
"eslint": "^2.4.0",
"eslint": "^4.10.0",
"istanbul": ">=0.3.13",
"jasmine-node": ">=1.14.5"
},
Expand Down
98 changes: 49 additions & 49 deletions spec/cli_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ describe(__filename, function () {
argv: ['node', 'variety-cli.js', '--help'],
process: null
})
.then(function(){
expect(ws.content).toContain('Usage: variety db_name/collection_name [options]');
done();
});
.then(function(){
expect(ws.content).toContain('Usage: variety db_name/collection_name [options]');
done();
});
});

it('CLI should correctly execute Variety', function (done) {
Expand All @@ -61,16 +61,16 @@ describe(__filename, function () {
argv: ['node', 'variety-cli.js', 'foo/bar', '--limit=5', '--host', 'localhost'],
process: null
})
.then(function(res) {
expect(res.bin).toEqual('mongo');
expect(res.args[0]).toEqual('foo'); //db name
expect(res.args[1]).toEqual('--eval=var collection="bar";var limit=5;'); //variety args
expect(res.args[2]).toEndWith('variety.js'); //library path
expect(res.args[3]).toEqual('--host'); //library path
expect(res.args[4]).toEqual('localhost'); //library path
done();
})
.catch(done);
.then(function(res) {
expect(res.bin).toEqual('mongo');
expect(res.args[0]).toEqual('foo'); //db name
expect(res.args[1]).toEqual('--eval=var collection="bar";var limit=5;'); //variety args
expect(res.args[2]).toEndWith('variety.js'); //library path
expect(res.args[3]).toEqual('--host'); //library path
expect(res.args[4]).toEqual('localhost'); //library path
done();
})
.catch(done);
});

it('CLI should forward auth arguments directly to mongo shell', function (done) {
Expand All @@ -87,20 +87,20 @@ describe(__filename, function () {
argv: ['node', 'variety-cli.js', 'foo/bar', '--username', 'lorem', '--password', 'ipsum', '--authenticationDatabase', 'my-auth-db'],
process: null
})
.then(function(res) {
expect(res.bin).toEqual('mongo');
expect(res.args[0]).toEqual('foo'); //db name
expect(res.args[1]).toEqual('--eval=var collection="bar";'); //variety args
expect(res.args[2]).toEndWith('variety.js'); //library path
expect(res.args[3]).toEqual('--username');
expect(res.args[4]).toEqual('lorem');
expect(res.args[5]).toEqual('--password');
expect(res.args[6]).toEqual('ipsum');
expect(res.args[7]).toEqual('--authenticationDatabase');
expect(res.args[8]).toEqual('my-auth-db');
done();
})
.catch(done);
.then(function(res) {
expect(res.bin).toEqual('mongo');
expect(res.args[0]).toEqual('foo'); //db name
expect(res.args[1]).toEqual('--eval=var collection="bar";'); //variety args
expect(res.args[2]).toEndWith('variety.js'); //library path
expect(res.args[3]).toEqual('--username');
expect(res.args[4]).toEqual('lorem');
expect(res.args[5]).toEqual('--password');
expect(res.args[6]).toEqual('ipsum');
expect(res.args[7]).toEqual('--authenticationDatabase');
expect(res.args[8]).toEqual('my-auth-db');
done();
})
.catch(done);
});

it('CLI should handle short versions of mongo arguments (for example -u, -p)', function (done) {
Expand All @@ -117,20 +117,20 @@ describe(__filename, function () {
argv: ['node', 'variety-cli.js', 'foo/bar', '-u', 'lorem', '-p', 'ipsum', '--authenticationDatabase', 'my-auth-db'],
process: null
})
.then(function(res) {
expect(res.bin).toEqual('mongo');
expect(res.args[0]).toEqual('foo'); //db name
expect(res.args[1]).toEqual('--eval=var collection="bar";'); //variety args
expect(res.args[2]).toEndWith('variety.js'); //library path
expect(res.args[3]).toEqual('-u');
expect(res.args[4]).toEqual('lorem');
expect(res.args[5]).toEqual('-p');
expect(res.args[6]).toEqual('ipsum');
expect(res.args[7]).toEqual('--authenticationDatabase');
expect(res.args[8]).toEqual('my-auth-db');
done();
})
.catch(done);
.then(function(res) {
expect(res.bin).toEqual('mongo');
expect(res.args[0]).toEqual('foo'); //db name
expect(res.args[1]).toEqual('--eval=var collection="bar";'); //variety args
expect(res.args[2]).toEndWith('variety.js'); //library path
expect(res.args[3]).toEqual('-u');
expect(res.args[4]).toEqual('lorem');
expect(res.args[5]).toEqual('-p');
expect(res.args[6]).toEqual('ipsum');
expect(res.args[7]).toEqual('--authenticationDatabase');
expect(res.args[8]).toEqual('my-auth-db');
done();
})
.catch(done);
});

it('CLI should handle incorrect args and print error + help', function (done) {
Expand All @@ -146,13 +146,13 @@ describe(__filename, function () {
argv: ['node', 'variety-cli.js', 'foo/bar', '--sort', '{foo:bar)'], // incorrect brackets pair
process: null
})
.then(function() {
done(new Error('Should throw exception and continue in catch branch'));
})
.catch(function(err) {
expect(err.message).toContain('Failed to parse option');
done();
});
.then(function() {
done(new Error('Should throw exception and continue in catch branch'));
})
.catch(function(err) {
expect(err.message).toContain('Failed to parse option');
done();
});
});

});

0 comments on commit 88f37f7

Please sign in to comment.