Add Bitbucket tests

This commit is contained in:
joeybloggs
2016-01-07 15:51:13 -05:00
parent 4598745601
commit b6efbd9323
5 changed files with 2906 additions and 22 deletions
+4 -4
View File
@@ -36,7 +36,7 @@ const (
PullRequestCreatedEvent Event = "pullrequest:created"
PullRequestUpdatedEvent Event = "pullrequest:updated"
PullRequestApprovedEvent Event = "pullrequest:approved"
PullRequestUnapprovedEvent Event = "pullrequest:unapproved"
PullRequestApprovalRemovedEvent Event = "pullrequest:unapproved"
PullRequestMergedEvent Event = "pullrequest:fulfilled"
PullRequestDeclinedEvent Event = "pullrequest:rejected"
PullRequestCommentCreatedEvent Event = "pullrequest:comment_created"
@@ -47,7 +47,7 @@ const (
// New creates and returns a WebHook instance denoted by the Provider type
func New(config *Config) *Webhook {
return &Webhook{
provider: webhooks.GitHub,
provider: webhooks.Bitbucket,
uuid: config.UUID,
eventFuncs: map[Event]webhooks.ProcessPayloadFunc{},
}
@@ -145,8 +145,8 @@ func (hook Webhook) ParsePayload(w http.ResponseWriter, r *http.Request) {
var pl PullRequestApprovedPayload
json.Unmarshal([]byte(payload), &pl)
hook.runProcessPayloadFunc(fn, pl)
case PullRequestUnapprovedEvent:
var pl PullRequestUnapprovedPayload
case PullRequestApprovalRemovedEvent:
var pl PullRequestApprovalRemovedPayload
json.Unmarshal([]byte(payload), &pl)
hook.runProcessPayloadFunc(fn, pl)
case PullRequestMergedEvent:
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -40,8 +40,8 @@ type PullRequestMergedPayload struct {
Repository Repository `json:"repository"`
}
// PullRequestUnapprovedPayload is the Bitbucket pullrequest:unapproved payload
type PullRequestUnapprovedPayload struct {
// PullRequestApprovalRemovedPayload is the Bitbucket pullrequest:unapproved payload
type PullRequestApprovalRemovedPayload struct {
Actor User `json:"actor"`
PullRequest PullRequest `json:"pullrequest"`
Repository Repository `json:"repository"`
+2
View File
@@ -9,6 +9,8 @@ func (p Provider) String() string {
switch p {
case GitHub:
return "GitHub"
case Bitbucket:
return "Bitbucket"
default:
return "Unknown"
}
+1
View File
@@ -235,5 +235,6 @@ D2lWusoe2/nEqfDVVWGWlyJ7yOmqaVm/iNUN9B2N2g==
func TestProviderString(t *testing.T) {
Equal(t, GitHub.String(), "GitHub")
Equal(t, Bitbucket.String(), "Bitbucket")
Equal(t, Provider(999999).String(), "Unknown")
}