From 7fae59beebb4d1ca2bdaa14434e019e59e5afa2d Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Thu, 24 Sep 2015 15:26:48 +0200 Subject: [PATCH] miglior gestione di un 404 nel recupero dei coverage report --- scripts/drone.coffee | 3 +++ test/drone-test.coffee | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/scripts/drone.coffee b/scripts/drone.coffee index 34b69f7..42e6b74 100644 --- a/scripts/drone.coffee +++ b/scripts/drone.coffee @@ -23,6 +23,9 @@ module.exports = (robot) -> try report = JSON.parse body catch e + if /^404/g.test body + return res.send 'Coverage report non disponibile (404) forse \ + non è ancora stato generato?' return res.send 'Errore: '+e+'\n\nRisposta del server: '+body unless report?.files?.push? and report?.coverage?.toFixed? return res.send 'Errore: informazioni insufficienti' diff --git a/test/drone-test.coffee b/test/drone-test.coffee index 7469bc6..0729b25 100644 --- a/test/drone-test.coffee +++ b/test/drone-test.coffee @@ -39,6 +39,15 @@ describe 'modulo drone', -> done() asjon.send 'asjon coverage' + it 'dovrebbe reagire correttamente quando il report non è disponibile (404)', (done) -> + nock('https://drone.io') + .get('/github.com/fazo96/asjon/files/coverage/coverage.json') + .reply 404, '404 page not found' + asjon.receive (e,l) -> + l.join().should.match /^Coverage report non disponibile/g + done() + asjon.send 'asjon coverage' + it 'dovrebbe parsare correttamente il report json', (done) -> nock('https://drone.io') .get('/github.com/fazo96/asjon/files/coverage/coverage.json')