mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-05 09:56:22 +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);
|
}, true);
|
||||||
}
|
}
|
||||||
Command.prototype.missingArgument = function(name) {
|
Command.prototype.missingArgument = function(name) {
|
||||||
if (this.name() !== 'new') {
|
_err.err({
|
||||||
throw {
|
fluenterror: this.name() !== 'new' ? HMSTATUS.resumeNotFound : HMSTATUS.createNameMissing
|
||||||
fluenterror: HMSTATUS.resumeNotFound,
|
}, true);
|
||||||
quit: true
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Command.prototype.helpInformation = function() {
|
Command.prototype.helpInformation = function() {
|
||||||
var manPage;
|
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;
|
return r;
|
||||||
}, this);
|
}, this);
|
||||||
if (this.hasError() && !opts.assert) {
|
if (this.hasError() && !opts.assert) {
|
||||||
this.reject(results);
|
this.reject(this.errorCode);
|
||||||
} else if (!this.hasError()) {
|
} else if (!this.hasError()) {
|
||||||
this.resolve(results);
|
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);
|
r = _validateOne.call(this, t, validator, schemas);
|
||||||
if (r.fluenterror) {
|
if (r.fluenterror) {
|
||||||
console.log(r);
|
|
||||||
r.quit = opts.assert;
|
r.quit = opts.assert;
|
||||||
this.err(r.fluenterror, r);
|
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;
|
payload["throw"] = hot;
|
||||||
this.setError(errorCode, payload);
|
this.setError(errorCode, payload);
|
||||||
if (payload.quit) {
|
if (payload.quit) {
|
||||||
this.reject(payload);
|
console.log(payload);
|
||||||
|
this.reject(errorCode);
|
||||||
}
|
}
|
||||||
this.fire('error', payload);
|
this.fire('error', payload);
|
||||||
if (hot) {
|
if (hot) {
|
||||||
|
@ -157,8 +157,14 @@ initialize = ( ar, exitCallback ) ->
|
|||||||
|
|
||||||
# Override the .missingArgument behavior
|
# Override the .missingArgument behavior
|
||||||
Command.prototype.missingArgument = (name) ->
|
Command.prototype.missingArgument = (name) ->
|
||||||
|
_err.err
|
||||||
|
fluenterror:
|
||||||
if this.name() != 'new'
|
if this.name() != 'new'
|
||||||
throw { fluenterror: HMSTATUS.resumeNotFound, quit: true }
|
then HMSTATUS.resumeNotFound
|
||||||
|
else HMSTATUS.createNameMissing
|
||||||
|
, true
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
# Override the .helpInformation behavior
|
# Override the .helpInformation behavior
|
||||||
Command.prototype.helpInformation = ->
|
Command.prototype.helpInformation = ->
|
||||||
|
@ -39,7 +39,7 @@ _create = ( src, dst, opts ) ->
|
|||||||
, @
|
, @
|
||||||
|
|
||||||
if @hasError() and !opts.assert
|
if @hasError() and !opts.assert
|
||||||
@reject results
|
@reject @errorCode
|
||||||
else if !@hasError()
|
else if !@hasError()
|
||||||
@resolve results
|
@resolve results
|
||||||
results
|
results
|
||||||
|
@ -43,7 +43,6 @@ _validate = (sources, unused, opts) ->
|
|||||||
return { } if @hasError() and opts.assert
|
return { } if @hasError() and opts.assert
|
||||||
r = _validateOne.call @, t, validator, schemas
|
r = _validateOne.call @, t, validator, schemas
|
||||||
if r.fluenterror
|
if r.fluenterror
|
||||||
console.log r
|
|
||||||
r.quit = opts.assert
|
r.quit = opts.assert
|
||||||
@err r.fluenterror, r
|
@err r.fluenterror, r
|
||||||
r
|
r
|
||||||
|
@ -64,7 +64,8 @@ Verb = module.exports = Class.extend
|
|||||||
payload.throw = hot
|
payload.throw = hot
|
||||||
@setError errorCode, payload
|
@setError errorCode, payload
|
||||||
if payload.quit
|
if payload.quit
|
||||||
@reject payload
|
console.log payload
|
||||||
|
@reject errorCode
|
||||||
@fire 'error', payload
|
@fire 'error', payload
|
||||||
if hot
|
if hot
|
||||||
throw payload
|
throw payload
|
||||||
|
@ -63,7 +63,7 @@ var tests = [
|
|||||||
' (multiple JRS resumes)'
|
' (multiple JRS resumes)'
|
||||||
],
|
],
|
||||||
|
|
||||||
[ '!new',
|
[ 'new',
|
||||||
[],
|
[],
|
||||||
[],
|
[],
|
||||||
opts,
|
opts,
|
||||||
@ -152,7 +152,7 @@ var tests = [
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
[ '!build',
|
[ 'build',
|
||||||
[ ft + 'jane-fullstacker.json'],
|
[ ft + 'jane-fullstacker.json'],
|
||||||
[ sb + 'shouldnt-exist.pdf' ],
|
[ sb + 'shouldnt-exist.pdf' ],
|
||||||
EXTEND(true, {}, opts, { theme: 'awesome' }),
|
EXTEND(true, {}, opts, { theme: 'awesome' }),
|
||||||
@ -172,16 +172,24 @@ describe('Testing API interface', function () {
|
|||||||
shouldSucceed = false;
|
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() {
|
function runIt() {
|
||||||
try {
|
try {
|
||||||
var v = new FCMD.verbs[verb]();
|
var v = new FCMD.verbs[verb]();
|
||||||
v.on('hmr:error', function(ex) { throw ex; });
|
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 )
|
||||||
if( !fnTest( r.sheet ) )
|
if( !fnTest( obj ) )
|
||||||
throw "Test: Unexpected API result.";
|
throw "Test: Unexpected API result.";
|
||||||
|
},
|
||||||
|
function( error ) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(ex) {
|
catch(ex) {
|
||||||
console.error(ex);
|
console.error(ex);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
4|
|
4|
|
||||||
0|--help
|
0|--help
|
||||||
0|-h
|
0|-h
|
||||||
0|--debug
|
4|--debug
|
||||||
0|-d
|
4|-d
|
||||||
5|notacommand
|
5|notacommand
|
||||||
8|new
|
8|new
|
||||||
0|new test/sandbox/cli-test/new-empty-resume.auto.json
|
0|new test/sandbox/cli-test/new-empty-resume.auto.json
|
||||||
|
Loading…
Reference in New Issue
Block a user