Skip to content
This repository has been archived by the owner on Jan 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #22 from dhollinger/add_more_fixtures
Browse files Browse the repository at this point in the history
Fix TFS checks and add more fixtures/tests
  • Loading branch information
dhollinger authored Nov 16, 2017
2 parents e47a8d9 + 2aaa2a7 commit 45ded79
Show file tree
Hide file tree
Showing 13 changed files with 1,578 additions and 23 deletions.
10 changes: 7 additions & 3 deletions lib/parsers/webhook_json_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def bitbucket_webhook?
def tfs_webhook?
# https://docs.microsoft.com/en-us/vsts/service-hooks/services/webhooks
return false unless @data.key? 'resource'
return false unless @data.key? 'event.type'
return false unless @data.key? 'eventType'
true
end

Expand All @@ -78,7 +78,8 @@ def branch
when 'stash'
@data['refChanges'][0]['refId'].sub('refs/heads/', '')
when 'bitbucket'
@data['push']['changes'][0]['new']['name']
return @data['push']['changes'][0]['new']['name'] unless deleted?
@data['push']['changes'][0]['old']['name']
when 'tfs'
@data['resource']['refUpdates'][0]['name'].sub('refs/heads/', '')
end
Expand All @@ -94,15 +95,18 @@ def deleted?
@data['refChanges'][0]['type'] == 'DELETE'
when 'bitbucket'
@data['push']['changes'][0]['closed']
when 'tfs'
@data['resource']['refUpdates'][0]['newObjectId'] == '0000000000000000000000000000000000000000'
else
# TODO: TFS
false
end
end

def repo_name
if @vcs == 'gitlab'
@data['project']['name']
elsif @vcs == 'tfs'
@data['resource']['repository']['name']
else
@data['repository']['name']
end
Expand Down
411 changes: 411 additions & 0 deletions spec/fixtures/bitbucket/create.json

Large diffs are not rendered by default.

131 changes: 131 additions & 0 deletions spec/fixtures/bitbucket/delete.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"push": {
"changes": [
{
"forced": false,
"old": {
"type": "branch",
"name": "add_branch",
"links": {
"commits": {
"href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commits/add_branch"
},
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/refs/branches/add_branch"
},
"html": {
"href": "https://bitbucket.org/dhollinger3/puppet-r10k/branch/add_branch"
}
},
"target": {
"hash": "31dfeec60f7f864b3f91ec6c61264595e1198ab8",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/31dfeec60f7f864b3f91ec6c61264595e1198ab8"
},
"html": {
"href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/31dfeec60f7f864b3f91ec6c61264595e1198ab8"
}
},
"author": {
"raw": "David Hollinger <[email protected]>",
"type": "author",
"user": {
"username": "dhollinger3",
"type": "user",
"display_name": "David Hollinger III",
"uuid": "{9a151b63-a0fb-4a20-a01f-99aefae76ac0}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/dhollinger3"
},
"html": {
"href": "https://bitbucket.org/dhollinger3/"
},
"avatar": {
"href": "https://bitbucket.org/account/dhollinger3/avatar/32/"
}
}
}
},
"parents": [
{
"type": "commit",
"hash": "65b4b4b14af68439fcd3ed0b7a13a80154e4735f",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/65b4b4b14af68439fcd3ed0b7a13a80154e4735f"
},
"html": {
"href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/65b4b4b14af68439fcd3ed0b7a13a80154e4735f"
}
}
}
],
"date": "2017-11-15T22:26:13+00:00",
"message": "Add .keep file\n",
"type": "commit"
}
},
"truncated": false,
"created": false,
"closed": true,
"new": null
}
]
},
"actor": {
"username": "dhollinger3",
"type": "user",
"display_name": "David Hollinger III",
"uuid": "{9a151b63-a0fb-4a20-a01f-99aefae76ac0}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/dhollinger3"
},
"html": {
"href": "https://bitbucket.org/dhollinger3/"
},
"avatar": {
"href": "https://bitbucket.org/account/dhollinger3/avatar/32/"
}
}
},
"repository": {
"scm": "git",
"website": "",
"name": "puppet-r10k",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k"
},
"html": {
"href": "https://bitbucket.org/dhollinger3/puppet-r10k"
},
"avatar": {
"href": "https://bitbucket.org/dhollinger3/puppet-r10k/avatar/32/"
}
},
"full_name": "dhollinger3/puppet-r10k",
"owner": {
"username": "dhollinger3",
"type": "user",
"display_name": "David Hollinger III",
"uuid": "{9a151b63-a0fb-4a20-a01f-99aefae76ac0}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/dhollinger3"
},
"html": {
"href": "https://bitbucket.org/dhollinger3/"
},
"avatar": {
"href": "https://bitbucket.org/account/dhollinger3/avatar/32/"
}
}
},
"type": "repository",
"is_private": true,
"uuid": "{f2d7282e-accb-46a1-b9d0-44bfe61b5af4}"
}
}
Loading

0 comments on commit 45ded79

Please sign in to comment.