Skip to content

Commit

Permalink
cover some error case
Browse files Browse the repository at this point in the history
  • Loading branch information
mose committed Aug 10, 2016
1 parent 72169b0 commit e33ac58
Showing 1 changed file with 52 additions and 27 deletions.
79 changes: 52 additions & 27 deletions test/phabs_templates_test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,58 @@ describe 'phabs_templates module', ->
expect(hubotResponse()).to.eql 'Template \'template1\' already exists.'

context 'and this template does not exist yet', ->
beforeEach ->
room.robot.brain.data.phabricator.templates = {
template1: { task: '123' }
}
do nock.disableNetConnect
nock(process.env.PHABRICATOR_URL)
.get('/api/maniphest.info')
.query({
'task_id': '333',
'api.token': 'xxx'
})
.reply(200, { result: {
status: 'open',
priority: 'Low',
name: 'Test task',
ownerPHID: 'PHID-USER-42'
} })


afterEach ->
room.robot.brain.data.phabricator = { }
nock.cleanAll()

context 'pht new template2 T333', ->
hubot 'pht new template2 T333'
it 'should reply that the template was created', ->
expect(hubotResponse()).to.eql 'Ok. Template \'template2\' will use T333.'
context 'but the task is not found', ->
beforeEach ->
room.robot.brain.data.phabricator.templates = {
template1: { task: '123' }
}
do nock.disableNetConnect
nock(process.env.PHABRICATOR_URL)
.get('/api/maniphest.info')
.query({
'task_id': '333',
'api.token': 'xxx'
})
.reply(200, { error_info: 'No such Maniphest task exists.' })


afterEach ->
room.robot.brain.data.phabricator = { }
nock.cleanAll()

context 'pht new template2 T333', ->
hubot 'pht new template2 T333'
it 'should reply that the template was created', ->
expect(hubotResponse()).to.eql 'No such Maniphest task exists.'

context 'and the task exists', ->
beforeEach ->
room.robot.brain.data.phabricator.templates = {
template1: { task: '123' }
}
do nock.disableNetConnect
nock(process.env.PHABRICATOR_URL)
.get('/api/maniphest.info')
.query({
'task_id': '333',
'api.token': 'xxx'
})
.reply(200, { result: {
status: 'open',
priority: 'Low',
name: 'Test task',
ownerPHID: 'PHID-USER-42'
} })


afterEach ->
room.robot.brain.data.phabricator = { }
nock.cleanAll()

context 'pht new template2 T333', ->
hubot 'pht new template2 T333'
it 'should reply that the template was created', ->
expect(hubotResponse()).to.eql 'Ok. Template \'template2\' will use T333.'

# ---------------------------------------------------------------------------------
context 'user wants info about a template', ->
Expand Down

0 comments on commit e33ac58

Please sign in to comment.