1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-07-05 01:20:06 +01:00
HackMyResume/test/scripts/test-cli.js

53 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-01-14 19:22:26 +00:00
/**
2016-02-11 17:08:11 +00:00
CLI test routines for HackMyResume. Test the HackMyResume command-line interface
by spawning HMR directly and observing the return code and std output.
2016-01-14 19:22:26 +00:00
@module test-cli.js
2016-02-11 17:08:11 +00:00
@license MIT. See LICENSE.md for details.
2016-01-14 19:22:26 +00:00
*/
var chai = require('chai')
, should = chai.should()
, expect = chai.expect
2016-01-14 19:22:26 +00:00
, FS = require('fs')
, PATH = require('path')
2016-02-02 21:18:38 +00:00
, EXEC = require('child_process').exec
2016-01-14 19:22:26 +00:00
2016-02-11 17:08:11 +00:00
describe('Testing CLI interface', function () {
2016-01-14 19:22:26 +00:00
this.timeout(50000);
2016-01-14 19:22:26 +00:00
function run( args, expErr ) {
var title = args;
2016-02-02 21:18:38 +00:00
it( 'Testing: "' + title + '"\n\n', function( done ) {
2016-02-02 02:14:36 +00:00
try {
2016-02-02 21:18:38 +00:00
EXEC('hackmyresume ' + args, null, function(err,stdo,stde) {
var errCode = (err && err.code) || 0;
errCode.should.equal( parseInt(expErr, 10) );
done();
});
2016-02-02 02:14:36 +00:00
}
catch(ex) {
2016-02-02 21:18:38 +00:00
ex.status.should.equal( parseInt(expErr, 10) );
done();
2016-02-02 02:14:36 +00:00
}
2016-01-14 19:22:26 +00:00
});
}
2016-02-11 17:08:11 +00:00
var testFile = PATH.join( __dirname, './test-hmr.txt');
var lines = FS.readFileSync( testFile, 'utf8').split('\n');
2016-01-14 19:22:26 +00:00
lines.forEach(function(l){
if( l && l.trim() ) {
if(l[0] !== '#') {
var lineInfo = l.split('|');
var errCode = lineInfo[0];
run( lineInfo.length > 1 ? lineInfo[1] : '', errCode );
}
}
});
});