Skip to content

Commit ee45bd2

Browse files
committed
test(cli): Added test for #15
1 parent f0a6094 commit ee45bd2

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ conventionalGithubReleaser({
101101
console.error(err.toString());
102102
process.exit(1);
103103
}
104-
104+
105105
if (0 === data.length) {
106106
console.log('No GitHub releases created because no git tags available to work with.');
107107
process.exit(0);

test/cli.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22
var expect = require('chai').expect;
33
var fs = require('fs');
4+
var Q = require('q');
45
var githubRemoveAllReleases = require('github-remove-all-releases');
56
var shell = require('shelljs');
67
var spawn = require('child_process').spawn;
@@ -64,6 +65,40 @@ describe('cli', function() {
6465
});
6566
});
6667

68+
it('should work with no releases', function(done) {
69+
Q.Promise(function(resolve, reject) {
70+
var cp = spawn(cliPath, ['--pkg', __dirname + '/fixtures/_package.json', '-t', AUTH.token, '-v'], {
71+
stdio: [process.stdin, null, null]
72+
});
73+
74+
cp.on('error', function(code) {
75+
reject('Process exits with code ' + code);
76+
});
77+
78+
cp.on('close', function(code) {
79+
expect(code).to.equal(0);
80+
81+
resolve();
82+
});
83+
}).then(function() {
84+
// we call it a second time, because there no tags are left to create a release from
85+
var cp = spawn(cliPath, ['--pkg', __dirname + '/fixtures/_package.json', '-t', AUTH.token, '-v'], {
86+
stdio: [process.stdin, null, null]
87+
});
88+
89+
cp.on('error', function(code) {
90+
done('Process exits with code ' + code);
91+
});
92+
93+
cp.on('close', function(code) {
94+
// this time we also expect the cli to exit with code 0 due to #17
95+
expect(code).to.equal(0);
96+
97+
done();
98+
});
99+
});
100+
});
101+
67102
it('should print out error message and exit with `1` if all results error', function(done) {
68103
var cp = spawn(cliPath, ['--pkg', __dirname + '/fixtures/_package.json', '-t', AUTH.token], {
69104
stdio: [process.stdin, null, null]

0 commit comments

Comments
 (0)