Add Bitbucket tests
This commit is contained in:
+20
-20
@@ -25,29 +25,29 @@ type Event string
|
||||
|
||||
// Bitbucket hook types
|
||||
const (
|
||||
RepoPushEvent Event = "repo:push"
|
||||
RepoForkEvent Event = "repo:fork"
|
||||
RepoCommitCommentCreatedEvent Event = "repo:commit_comment_created"
|
||||
RepoCommitStatusCreatedEvent Event = "repo:commit_status_created"
|
||||
RepoCommitStatusUpdatedEvent Event = "repo:commit_status_updated"
|
||||
IssueCreatedEvent Event = "issue:created"
|
||||
IssueUpdatedEvent Event = "issue:updated"
|
||||
IssueCommentCreatedEvent Event = "issue:comment_created"
|
||||
PullRequestCreatedEvent Event = "pullrequest:created"
|
||||
PullRequestUpdatedEvent Event = "pullrequest:updated"
|
||||
PullRequestApprovedEvent Event = "pullrequest:approved"
|
||||
PullRequestUnapprovedEvent Event = "pullrequest:unapproved"
|
||||
PullRequestMergedEvent Event = "pullrequest:fulfilled"
|
||||
PullRequestDeclinedEvent Event = "pullrequest:rejected"
|
||||
PullRequestCommentCreatedEvent Event = "pullrequest:comment_created"
|
||||
PullRequestCommentUpdatedEvent Event = "pullrequest:comment_updated"
|
||||
PullRequestCommentDeletedEvent Event = "pull_request:comment_deleted"
|
||||
RepoPushEvent Event = "repo:push"
|
||||
RepoForkEvent Event = "repo:fork"
|
||||
RepoCommitCommentCreatedEvent Event = "repo:commit_comment_created"
|
||||
RepoCommitStatusCreatedEvent Event = "repo:commit_status_created"
|
||||
RepoCommitStatusUpdatedEvent Event = "repo:commit_status_updated"
|
||||
IssueCreatedEvent Event = "issue:created"
|
||||
IssueUpdatedEvent Event = "issue:updated"
|
||||
IssueCommentCreatedEvent Event = "issue:comment_created"
|
||||
PullRequestCreatedEvent Event = "pullrequest:created"
|
||||
PullRequestUpdatedEvent Event = "pullrequest:updated"
|
||||
PullRequestApprovedEvent Event = "pullrequest:approved"
|
||||
PullRequestApprovalRemovedEvent Event = "pullrequest:unapproved"
|
||||
PullRequestMergedEvent Event = "pullrequest:fulfilled"
|
||||
PullRequestDeclinedEvent Event = "pullrequest:rejected"
|
||||
PullRequestCommentCreatedEvent Event = "pullrequest:comment_created"
|
||||
PullRequestCommentUpdatedEvent Event = "pullrequest:comment_updated"
|
||||
PullRequestCommentDeletedEvent Event = "pull_request:comment_deleted"
|
||||
)
|
||||
|
||||
// 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
@@ -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"`
|
||||
|
||||
@@ -9,6 +9,8 @@ func (p Provider) String() string {
|
||||
switch p {
|
||||
case GitHub:
|
||||
return "GitHub"
|
||||
case Bitbucket:
|
||||
return "Bitbucket"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user