add null checks and defaults for the cached smoke test results

This commit is contained in:
Henry Oswald 2014-06-05 16:13:06 +01:00
parent 98efa96f3e
commit 8d337a26db

View file

@ -45,14 +45,19 @@ resCacher =
contentType:(@setContentType)-> contentType:(@setContentType)->
send:(@code, @body)-> send:(@code, @body)->
#default the server to be down
code:500
body:{}
setContentType:"application/json"
do runSmokeTest = -> do runSmokeTest = ->
logger.log("running smoke tests") logger.log("running smoke tests")
smokeTest.run(require.resolve(__dirname + "/test/smoke/js/SmokeTests.js"))({}, resCacher) smokeTest.run(require.resolve(__dirname + "/test/smoke/js/SmokeTests.js"))({}, resCacher)
setTimeout(runSmokeTest, 20 * 1000) setTimeout(runSmokeTest, 20 * 1000)
app.get "/health_check", (req, res)-> app.get "/health_check", (req, res)->
res.contentType(resCacher.setContentType) res.contentType(resCacher?.setContentType)
res.send resCacher.code, resCacher.body res.send resCacher?.code, resCacher?.body
app.use (error, req, res, next) -> app.use (error, req, res, next) ->
logger.error err: error, "server error" logger.error err: error, "server error"