mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-05 01:56:21 +00:00
Adjust error handling / tests.
This commit is contained in:
parent
70f45d468d
commit
fd39cc9fd9
9
dist/cli/main.js
vendored
9
dist/cli/main.js
vendored
@ -119,12 +119,9 @@ Definition of the `main` function.
|
||||
}, true);
|
||||
}
|
||||
Command.prototype.missingArgument = function(name) {
|
||||
if (this.name() !== 'new') {
|
||||
throw {
|
||||
fluenterror: HMSTATUS.resumeNotFound,
|
||||
quit: true
|
||||
};
|
||||
}
|
||||
_err.err({
|
||||
fluenterror: this.name() !== 'new' ? HMSTATUS.resumeNotFound : HMSTATUS.createNameMissing
|
||||
}, true);
|
||||
};
|
||||
Command.prototype.helpInformation = function() {
|
||||
var manPage;
|
||||
|
2
dist/verbs/create.js
vendored
2
dist/verbs/create.js
vendored
@ -52,7 +52,7 @@ Implementation of the 'create' verb for HackMyResume.
|
||||
return r;
|
||||
}, this);
|
||||
if (this.hasError() && !opts.assert) {
|
||||
this.reject(results);
|
||||
this.reject(this.errorCode);
|
||||
} else if (!this.hasError()) {
|
||||
this.resolve(results);
|
||||
}
|
||||
|
1
dist/verbs/validate.js
vendored
1
dist/verbs/validate.js
vendored
@ -58,7 +58,6 @@ Implementation of the 'validate' verb for HackMyResume.
|
||||
}
|
||||
r = _validateOne.call(this, t, validator, schemas);
|
||||
if (r.fluenterror) {
|
||||
console.log(r);
|
||||
r.quit = opts.assert;
|
||||
this.err(r.fluenterror, r);
|
||||
}
|
||||
|
3
dist/verbs/verb.js
vendored
3
dist/verbs/verb.js
vendored
@ -66,7 +66,8 @@ Definition of the Verb class.
|
||||
payload["throw"] = hot;
|
||||
this.setError(errorCode, payload);
|
||||
if (payload.quit) {
|
||||
this.reject(payload);
|
||||
console.log(payload);
|
||||
this.reject(errorCode);
|
||||
}
|
||||
this.fire('error', payload);
|
||||
if (hot) {
|
||||
|
@ -157,8 +157,14 @@ initialize = ( ar, exitCallback ) ->
|
||||
|
||||
# Override the .missingArgument behavior
|
||||
Command.prototype.missingArgument = (name) ->
|
||||
_err.err
|
||||
fluenterror:
|
||||
if this.name() != 'new'
|
||||
throw { fluenterror: HMSTATUS.resumeNotFound, quit: true }
|
||||
then HMSTATUS.resumeNotFound
|
||||
else HMSTATUS.createNameMissing
|
||||
, true
|
||||
return
|
||||
|
||||
|
||||
# Override the .helpInformation behavior
|
||||
Command.prototype.helpInformation = ->
|
||||
|
@ -39,7 +39,7 @@ _create = ( src, dst, opts ) ->
|
||||
, @
|
||||
|
||||
if @hasError() and !opts.assert
|
||||
@reject results
|
||||
@reject @errorCode
|
||||
else if !@hasError()
|
||||
@resolve results
|
||||
results
|
||||
|
@ -43,7 +43,6 @@ _validate = (sources, unused, opts) ->
|
||||
return { } if @hasError() and opts.assert
|
||||
r = _validateOne.call @, t, validator, schemas
|
||||
if r.fluenterror
|
||||
console.log r
|
||||
r.quit = opts.assert
|
||||
@err r.fluenterror, r
|
||||
r
|
||||
|
@ -64,7 +64,8 @@ Verb = module.exports = Class.extend
|
||||
payload.throw = hot
|
||||
@setError errorCode, payload
|
||||
if payload.quit
|
||||
@reject payload
|
||||
console.log payload
|
||||
@reject errorCode
|
||||
@fire 'error', payload
|
||||
if hot
|
||||
throw payload
|
||||
|
@ -63,7 +63,7 @@ var tests = [
|
||||
' (multiple JRS resumes)'
|
||||
],
|
||||
|
||||
[ '!new',
|
||||
[ 'new',
|
||||
[],
|
||||
[],
|
||||
opts,
|
||||
@ -152,7 +152,7 @@ var tests = [
|
||||
}
|
||||
],
|
||||
|
||||
[ '!build',
|
||||
[ 'build',
|
||||
[ ft + 'jane-fullstacker.json'],
|
||||
[ sb + 'shouldnt-exist.pdf' ],
|
||||
EXTEND(true, {}, opts, { theme: 'awesome' }),
|
||||
@ -172,16 +172,24 @@ describe('Testing API interface', function () {
|
||||
shouldSucceed = false;
|
||||
}
|
||||
|
||||
it( 'The ' + verb.toUpperCase() + ' command should ' + (shouldSucceed ? ' SUCCEED' : ' FAIL') + msg, function () {
|
||||
it( 'The ' + verb.toUpperCase() + ' command should ' + (shouldSucceed ? ' NOT THROW' : ' THROW') + msg, function () {
|
||||
|
||||
function runIt() {
|
||||
try {
|
||||
var v = new FCMD.verbs[verb]();
|
||||
v.on('hmr:error', function(ex) { throw ex; });
|
||||
var r = v.invoke( src, dst, opts );
|
||||
var prom = v.invoke( src, dst, opts );
|
||||
prom.then(
|
||||
function( obj ) {
|
||||
if( fnTest )
|
||||
if( !fnTest( r.sheet ) )
|
||||
if( !fnTest( obj ) )
|
||||
throw "Test: Unexpected API result.";
|
||||
},
|
||||
function( error ) {
|
||||
throw error;
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
catch(ex) {
|
||||
console.error(ex);
|
||||
|
@ -1,8 +1,8 @@
|
||||
4|
|
||||
0|--help
|
||||
0|-h
|
||||
0|--debug
|
||||
0|-d
|
||||
4|--debug
|
||||
4|-d
|
||||
5|notacommand
|
||||
8|new
|
||||
0|new test/sandbox/cli-test/new-empty-resume.auto.json
|
||||
|
Loading…
Reference in New Issue
Block a user