Skip to content

Commit

Permalink
test(cli): Added test for #15
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinkert committed Jan 23, 2017
1 parent f0a6094 commit ee45bd2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli.js
Expand Up @@ -101,7 +101,7 @@ conventionalGithubReleaser({
console.error(err.toString());
process.exit(1);
}

if (0 === data.length) {
console.log('No GitHub releases created because no git tags available to work with.');
process.exit(0);
Expand Down
35 changes: 35 additions & 0 deletions test/cli.js
@@ -1,6 +1,7 @@
'use strict';
var expect = require('chai').expect;
var fs = require('fs');
var Q = require('q');
var githubRemoveAllReleases = require('github-remove-all-releases');
var shell = require('shelljs');
var spawn = require('child_process').spawn;
Expand Down Expand Up @@ -64,6 +65,40 @@ describe('cli', function() {
});
});

it('should work with no releases', function(done) {
Q.Promise(function(resolve, reject) {
var cp = spawn(cliPath, ['--pkg', __dirname + '/fixtures/_package.json', '-t', AUTH.token, '-v'], {
stdio: [process.stdin, null, null]
});

cp.on('error', function(code) {
reject('Process exits with code ' + code);
});

cp.on('close', function(code) {
expect(code).to.equal(0);

resolve();
});
}).then(function() {
// we call it a second time, because there no tags are left to create a release from
var cp = spawn(cliPath, ['--pkg', __dirname + '/fixtures/_package.json', '-t', AUTH.token, '-v'], {
stdio: [process.stdin, null, null]
});

cp.on('error', function(code) {
done('Process exits with code ' + code);
});

cp.on('close', function(code) {
// this time we also expect the cli to exit with code 0 due to #17
expect(code).to.equal(0);

done();
});
});
});

it('should print out error message and exit with `1` if all results error', function(done) {
var cp = spawn(cliPath, ['--pkg', __dirname + '/fixtures/_package.json', '-t', AUTH.token], {
stdio: [process.stdin, null, null]
Expand Down

0 comments on commit ee45bd2

Please sign in to comment.