Skip to content

Commit

Permalink
Added bad push JSON for GitLab hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaume Florez committed Aug 30, 2016
1 parent 2f4e816 commit e6ff95d
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions spec/format_gitlab_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@
hook = gitlab(json_data)
expect(hook.branch_name()).to(equal('markdown'))

with it('may return none when getting branch name if commenting'
' something else (not request or issue)'):
file = 'comment_commit.json'
data = open(join(data_path, file)).read()
json_data = loads(data)
hook = gitlab(json_data)
expect(hook.branch_name()).to(equal('None'))

with context('Issue Event'):
with it('must have "issue" as event'):
file = 'issue.json'
Expand All @@ -152,8 +160,7 @@
hook = gitlab(json_data)
expect(hook.event).to(equal('merge_request'))

with it('may return branch name if commenting request '
'(master on merge_request.json)'):
with it('may return branch name (master on merge_request.json)'):
file = 'merge_request.json'
data = open(join(data_path, file)).read()
json_data = loads(data)
Expand All @@ -168,8 +175,7 @@
hook = gitlab(json_data)
expect(hook.event).to(equal('push'))

with it('may return branch name if commenting request '
'(master on push.json)'):
with it('may return branch name (master on push.json)'):
file = 'push.json'
data = open(join(data_path, file)).read()
json_data = loads(data)
Expand All @@ -183,3 +189,18 @@
json_data = loads(data)
hook = gitlab(json_data)
expect(hook.event).to(equal('tag_push'))

with context('Bad JSON for push event'):
with it('must return push as event'):
file = 'bad_push.json'
data = open(join(data_path, file)).read()
json_data = loads(data)
hook = gitlab(json_data)
expect(hook.event).to(equal('push'))

with it('must return None as branch name'):
file = 'bad_push.json'
data = open(join(data_path, file)).read()
json_data = loads(data)
hook = gitlab(json_data)
expect(hook.branch_name()).to(equal('None'))

0 comments on commit e6ff95d

Please sign in to comment.