Skip to content

Commit

Permalink
Webhook events (#222)
Browse files Browse the repository at this point in the history
* feat(webhooks): Add constants for webhook events

* test(webhooks): Update tests to use constants

Co-authored-by: Thomas O'Neill <toneill@new-innov.com>
  • Loading branch information
toneill818 and toneill-newinnov committed Sep 22, 2022
1 parent c59b996 commit f850913
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/webhooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestWebhook(t *testing.T) {
Description: "go-bb-test",
Url: "https://example.com",
Active: false,
Events: []string{"repo:push", "issue:created"},
Events: []string{bitbucket.RepoPushEvent, bitbucket.IssueCreatedEvent},
}

webhook, err := c.Repositories.Webhooks.Create(opt)
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestWebhook(t *testing.T) {
Uuid: webhookResourceUuid,
Description: "go-bb-test-new",
Url: "https://new-example.com",
Events: []string{"repo:push", "issue:created", "repo:fork"},
Events: []string{bitbucket.RepoPushEvent, bitbucket.IssueCreatedEvent, bitbucket.RepoForkEvent},
}
webhook, err := c.Repositories.Webhooks.Update(opt)
if err != nil {
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestWebhook(t *testing.T) {
Description: fmt.Sprintf("go-bb-test-%d", i),
Url: fmt.Sprintf("https://example.com/%d", i),
Active: false,
Events: []string{"repo:push", "issue:created"},
Events: []string{bitbucket.RepoPushEvent, bitbucket.IssueCreatedEvent},
}

webhook, err := c.Repositories.Webhooks.Create(opt)
Expand Down
22 changes: 22 additions & 0 deletions webhookEvents.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package bitbucket

const (
RepoPushEvent string = "repo:push"
RepoForkEvent string = "repo:fork"
RepoUpdatedEvent string = "repo:updated"
RepoCommitCommentCreatedEvent string = "repo:commit_comment_created"
RepoCommitStatusCreatedEvent string = "repo:commit_status_created"
RepoCommitStatusUpdatedEvent string = "repo:commit_status_updated"
IssueCreatedEvent string = "issue:created"
IssueUpdatedEvent string = "issue:updated"
IssueCommentCreatedEvent string = "issue:comment_created"
PullRequestCreatedEvent string = "pullrequest:created"
PullRequestUpdatedEvent string = "pullrequest:updated"
PullRequestApprovedEvent string = "pullrequest:approved"
PullRequestUnapprovedEvent string = "pullrequest:unapproved"
PullRequestMergedEvent string = "pullrequest:fulfilled"
PullRequestDeclinedEvent string = "pullrequest:rejected"
PullRequestCommentCreatedEvent string = "pullrequest:comment_created"
PullRequestCommentUpdatedEvent string = "pullrequest:comment_updated"
PullRequestCommentDeletedEvent string = "pullrequest:comment_deleted"
)

0 comments on commit f850913

Please sign in to comment.