From 880319e035f5099619dabd431972a35c232166d5 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Mon, 11 Jun 2018 23:50:40 +0000 Subject: [PATCH] separate api and git url --- scripts/git.coffee | 6 ++++-- test/git-test.coffee | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/git.coffee b/scripts/git.coffee index 9ea5fc6..f31f148 100644 --- a/scripts/git.coffee +++ b/scripts/git.coffee @@ -5,7 +5,8 @@ # None # # Configuration: -# HUBOT_GIT_URL - git server API base url +# HUBOT_GIT_URL - git server url +# HUBOT_GIT_API - git server API url # HUBOT_GIT_TOKEN - Gogs v1 or GitHub v3 API token # HUBOT_GIT_REPO - repository name (owner/repo) # @@ -33,7 +34,7 @@ module.exports = (robot) -> robot.respond /(?:(?:mostra(?:mi)?|fammi vedere) )?(?:le )?issue(?:s)?/i, (res) -> msg = state: 'open', user: 'rnhmjoj', repo: 'asjon', sort: 'updated' res.send 'controllo issues...' - url = process.env.HUBOT_GIT_URL + url = process.env.HUBOT_GIT_API repo = process.env.HUBOT_GIT_REPO token = process.env.HUBOT_GIT_TOKEN @@ -59,6 +60,7 @@ module.exports = (robot) -> res.send base+res.match[1] robot.respond /linkami (?:la )?repo (\w+\/\w+)/i, (res) -> + url = process.env.HUBOT_GIT_URL res.send "#{url}/#{res.match[1]}/" # rendo l'handler dell'hook di git accessibile diff --git a/test/git-test.coffee b/test/git-test.coffee index e30a92d..3c06a33 100644 --- a/test/git-test.coffee +++ b/test/git-test.coffee @@ -15,6 +15,7 @@ describe 'modulo git', -> githook = require('../scripts/git.coffee')(asjon.robot) done() process.env.HUBOT_GIT_URL = 'https://git.example.com' + process.env.HUBOT_GIT_API = 'https://api.example.com' process.env.HUBOT_GIT_REPO = 'owner/asjon' process.env.HUBOT_GIT_TOKEN = 'secret' @@ -26,7 +27,7 @@ describe 'modulo git', -> "asjon le issue" "asjon issue" ] - nock('https://git.example.com') + nock('https://api.example.com') .get('/repos/owner/asjon/issues?state=open&sort=updated') .times(questions.length) .reply 200, [] @@ -37,7 +38,7 @@ describe 'modulo git', -> questions.map (q) -> asjon.send q it 'dovrebbe rispondere correttamente in caso di 0 issues', (done) -> - nock('https://git.example.com') + nock('https://api.example.com') .get('/repos/owner/asjon/issues?state=open&sort=updated') .reply 200, [] acc = 0 @@ -65,7 +66,7 @@ describe 'modulo git', -> login: 'user' it 'dovrebbe rispondere correttamente in caso di 1 o piĆ¹ issues', (done) -> - nock('https://git.example.com') + nock('https://api.example.com') .get('/repos/owner/asjon/issues?state=open&sort=updated') .reply 200, [issue1, issue2] acc = 0