fix unhandled exception in ProjectDetailsHandler

This commit is contained in:
Brian Gough 2017-03-28 09:44:50 +01:00
parent 30c5bbfdfc
commit 4e66b045e3
2 changed files with 8 additions and 1 deletions

View file

@ -10,7 +10,7 @@ module.exports =
getDetails: (project_id, callback)->
ProjectGetter.getProject project_id, {name:true, description:true, compiler:true, features:true, owner_ref:true}, (err, project)->
if err?
if err? or !project?
logger.err err:err, project_id:project_id, "error getting project"
return callback(err)
UserGetter.getUser project.owner_ref, (err, user) ->

View file

@ -48,6 +48,13 @@ describe 'ProjectDetailsHandler', ->
assert.equal(details.something, undefined)
done()
it "should return an error for a non-existent project", (done)->
@ProjectGetter.getProject.callsArg(2, null, null)
@handler.getDetails "0123456789012345678901234", (err, details)=>
assert.equal(err, undefined)
assert.equal(details, undefined)
done()
it "should return the error", (done)->
error = "some error"
@ProjectGetter.getProject.callsArgWith(2, error)