separate api and git url

This commit is contained in:
Michele Guerini Rocco 2018-06-11 23:50:40 +00:00
parent 5fdb274023
commit 880319e035
Signed by: rnhmjoj
GPG Key ID: 91BE884FBA4B591A
2 changed files with 8 additions and 5 deletions

View File

@ -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

View File

@ -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