From d8077143956a9a4ee6b6cec3c3c6f204d0fd8e10 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Wed, 29 Apr 2015 15:35:16 +0200 Subject: [PATCH] fix robaccia che ho dimenticato nell'ultimo commit --- scripts/drone.coffee | 4 ++-- scripts/github.coffee | 9 ++++++++- test/drone-test.coffee | 2 +- test/wolfram-test.coffee | 19 +------------------ 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/scripts/drone.coffee b/scripts/drone.coffee index aa04d6b..29211ce 100644 --- a/scripts/drone.coffee +++ b/scripts/drone.coffee @@ -23,9 +23,9 @@ module.exports = (robot) -> try report = JSON.parse body catch e - return res.send 'errore' + return res.send 'Errore: '+e unless report?.files?.push? and report?.coverage?.toFixed? - return res.send 'errore' + return res.send 'Errore: informazioni insufficienti' t = '=== Coverage: ' + report.coverage.toFixed(0) + '%' t += report.files.map (f) -> '\n - ' + f.filename + ' is covered at ' + f.coverage.toFixed(0) + '%' diff --git a/scripts/github.coffee b/scripts/github.coffee index 26aaccb..9a5493c 100644 --- a/scripts/github.coffee +++ b/scripts/github.coffee @@ -18,7 +18,7 @@ module.exports = (robot) -> r = room: process.env.AUTO_INFORM_ON_START.replace(':','#') robot.send r, 'asjon avviato e operativo!' - robot.router.post '/hubot/githubhook/:room/:name?', (req, res) -> + githubhook = (req, res) -> res.send 200 dest = name: req.params.name, room: req.params.room.replace(':','#') robot.emit 'githubhook', req.body, req.params @@ -26,6 +26,9 @@ module.exports = (robot) -> cm = req.body.commits.map (c) -> [c.committer.username,c.message].join ' -> ' robot.send dest, s+cm.join('\n') + unless process.env.TESTING_ASJON + # Disabilito http route durante i test + robot.router.post '/hubot/githubhook/:room/:name?', robot.respond /(?:(?:mostra(?:mi)?|fammi vedere) )?(?:le )?issue(?:s)?/i, (res) -> msg = state: 'open', user: 'fazo96', repo: 'asjon', sort: 'updated' @@ -46,3 +49,7 @@ module.exports = (robot) -> robot.respond /linkami (?:la )?repo (\w+\/\w+)/i, (res) -> res.send 'https://github.com/'+res.match[1] + # rendo l'handler dell'hook di github accessibile + # in caso serve (nei test) + return githubhook + diff --git a/test/drone-test.coffee b/test/drone-test.coffee index 30ae371..7469bc6 100644 --- a/test/drone-test.coffee +++ b/test/drone-test.coffee @@ -35,7 +35,7 @@ describe 'modulo drone', -> .get('/github.com/fazo96/asjon/files/coverage/coverage.json') .reply 200, 'invalid answer' asjon.receive (e,l) -> - l.join().should.equal 'errore' + l.join().should.match /^Errore: SyntaxError: Unexpected token/g done() asjon.send 'asjon coverage' diff --git a/test/wolfram-test.coffee b/test/wolfram-test.coffee index 59c6346..c3fdc7d 100644 --- a/test/wolfram-test.coffee +++ b/test/wolfram-test.coffee @@ -4,7 +4,7 @@ expect = require("chai").should() Asjon = require '../asjon-testing.coffee' asjon = undefined -describe 'modulo github', -> +describe 'modulo wolfram', -> before (done) -> # Inizializzo robot Asjon (assa) -> @@ -53,20 +53,3 @@ describe 'modulo github', -> acc++ if acc is 2 then done() asjon.send 'asjon wfa test' - it.skip 'dovrebbe rispondere a "mostra le issues"', (done) -> - questions = [ - "asjon mostrami le issue" - "asjon mostrami le issues" - "asjon issues" - "asjon le issue" - "asjon issue" - ] - nock('https://api.github.com') - .get('/repos/fazo96/asjon/issues?state=open&sort=updated') - .times(questions.length) - .reply 200, [] - acc = 0 - asjon.receive (e,l) -> - acc++ - if acc is questions.length*2 then done() - questions.map (q) -> asjon.send q