Skip to content

Commit

Permalink
cover an edgy case
Browse files Browse the repository at this point in the history
  • Loading branch information
mose committed Jul 24, 2016
1 parent eba57fb commit f129d5e
Showing 1 changed file with 88 additions and 49 deletions.
137 changes: 88 additions & 49 deletions test/phabs_admin_test.coffee
Expand Up @@ -184,58 +184,97 @@ describe 'phabs_admin module', ->

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
context 'when project has no phid recorded', ->
beforeEach ->
room.robot.brain.data.phabricator.projects = {
'Bug Report': { },
'project with phid': { phid: 'PHID-PROJ-1234567' },
}
room.robot.brain.data.phabricator.aliases = { }
do nock.disableNetConnect
nock(process.env.PHABRICATOR_URL)
.get('/api/project.query')
.query({
'names[0]': 'project1',
'api.token': 'xxx'
})
.reply(200, { result: {
'data': {
'PHID-PROJ-qhmexneudkt62wc7o3z4': {
'id': '1402',
'phid': 'PHID-PROJ-qhmexneudkt62wc7o3z4',
'name': 'Bug Report',
'profileImagePHID': 'PHID-FILE-2dsjotf2zgtbludzlk4s',
'icon': 'bugs',
'color': 'yellow',
'members': [
'PHID-USER-3yc34eijivr6rqs4vgiw',
'PHID-USER-7k37pmi3jffv46mzs5te'
],
'slugs': [
'bug_report'
],
'dateCreated': '1449275954',
'dateModified': '1468138110'
context 'and the project is known', ->
beforeEach ->
room.robot.brain.data.phabricator.projects = {
'Bug Report': { },
'project with phid': { phid: 'PHID-PROJ-1234567' },
}
room.robot.brain.data.phabricator.aliases = { }
do nock.disableNetConnect
nock(process.env.PHABRICATOR_URL)
.get('/api/project.query')
.query({
'names[0]': 'project1',
'api.token': 'xxx'
})
.reply(200, { result: {
'data': {
'PHID-PROJ-qhmexneudkt62wc7o3z4': {
'id': '1402',
'phid': 'PHID-PROJ-qhmexneudkt62wc7o3z4',
'name': 'Bug Report',
'profileImagePHID': 'PHID-FILE-2dsjotf2zgtbludzlk4s',
'icon': 'bugs',
'color': 'yellow',
'members': [
'PHID-USER-3yc34eijivr6rqs4vgiw',
'PHID-USER-7k37pmi3jffv46mzs5te'
],
'slugs': [
'bug_report'
],
'dateCreated': '1449275954',
'dateModified': '1468138110'
}
},
'slugMap': [ ],
'cursor': {
'limit': 100,
'after': null,
'before': null
}
},
'slugMap': [ ],
'cursor': {
'limit': 100,
'after': null,
'before': null
}
} })
} })

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

context 'phad Bug Report info', ->
hubot 'phad Bug Report info'
it 'should reply with proper info', ->
expect(hubotResponse()).to.eql 'Bug Report is Bug Report, with no alias, with no feed.'
it 'should remember the phid from asking to phabricator', ->
expect(room.robot.brain.data.phabricator.projects['Bug Report'].phid)
.to.eql 'PHID-PROJ-qhmexneudkt62wc7o3z4'
context 'phad Bug Report info', ->
hubot 'phad Bug Report info'
it 'should reply with proper info', ->
expect(hubotResponse()).to.eql 'Bug Report is Bug Report, with no alias, with no feed.'
it 'should remember the phid from asking to phabricator', ->
expect(room.robot.brain.data.phabricator.projects['Bug Report'].phid)
.to.eql 'PHID-PROJ-qhmexneudkt62wc7o3z4'


context 'and the project is unknown to phabricator', ->
beforeEach ->
room.robot.brain.data.phabricator.projects = {
'Bug Report': { },
'project with phid': { phid: 'PHID-PROJ-1234567' },
}
room.robot.brain.data.phabricator.aliases = {
bugs: 'project with phid',
bug: 'project with phid'
}
do nock.disableNetConnect
nock(process.env.PHABRICATOR_URL)
.get('/api/project.query')
.query({
'names[0]': 'project1',
'api.token': 'xxx'
})
.reply(200, { result: {
'data': [ ],
'slugMap': [ ],
'cursor': {
'limit': 100,
'after': null,
'before': null
}
} })

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

context 'phad unknown info', ->
hubot 'phad unknown info'
it 'should reply with proper info', ->
expect(hubotResponse())
.to.eql 'Project unknown not found.'

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
context 'when project has phid recorded, and aliases', ->
Expand Down

0 comments on commit f129d5e

Please sign in to comment.