Skip to content

Commit f850913

Browse files
Webhook events (ktrysmt#222)
* feat(webhooks): Add constants for webhook events * test(webhooks): Update tests to use constants Co-authored-by: Thomas O'Neill <[email protected]>
1 parent c59b996 commit f850913

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

tests/webhooks_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestWebhook(t *testing.T) {
3939
Description: "go-bb-test",
4040
Url: "https://example.com",
4141
Active: false,
42-
Events: []string{"repo:push", "issue:created"},
42+
Events: []string{bitbucket.RepoPushEvent, bitbucket.IssueCreatedEvent},
4343
}
4444

4545
webhook, err := c.Repositories.Webhooks.Create(opt)
@@ -103,7 +103,7 @@ func TestWebhook(t *testing.T) {
103103
Uuid: webhookResourceUuid,
104104
Description: "go-bb-test-new",
105105
Url: "https://new-example.com",
106-
Events: []string{"repo:push", "issue:created", "repo:fork"},
106+
Events: []string{bitbucket.RepoPushEvent, bitbucket.IssueCreatedEvent, bitbucket.RepoForkEvent},
107107
}
108108
webhook, err := c.Repositories.Webhooks.Update(opt)
109109
if err != nil {
@@ -164,7 +164,7 @@ func TestWebhook(t *testing.T) {
164164
Description: fmt.Sprintf("go-bb-test-%d", i),
165165
Url: fmt.Sprintf("https://example.com/%d", i),
166166
Active: false,
167-
Events: []string{"repo:push", "issue:created"},
167+
Events: []string{bitbucket.RepoPushEvent, bitbucket.IssueCreatedEvent},
168168
}
169169

170170
webhook, err := c.Repositories.Webhooks.Create(opt)

webhookEvents.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package bitbucket
2+
3+
const (
4+
RepoPushEvent string = "repo:push"
5+
RepoForkEvent string = "repo:fork"
6+
RepoUpdatedEvent string = "repo:updated"
7+
RepoCommitCommentCreatedEvent string = "repo:commit_comment_created"
8+
RepoCommitStatusCreatedEvent string = "repo:commit_status_created"
9+
RepoCommitStatusUpdatedEvent string = "repo:commit_status_updated"
10+
IssueCreatedEvent string = "issue:created"
11+
IssueUpdatedEvent string = "issue:updated"
12+
IssueCommentCreatedEvent string = "issue:comment_created"
13+
PullRequestCreatedEvent string = "pullrequest:created"
14+
PullRequestUpdatedEvent string = "pullrequest:updated"
15+
PullRequestApprovedEvent string = "pullrequest:approved"
16+
PullRequestUnapprovedEvent string = "pullrequest:unapproved"
17+
PullRequestMergedEvent string = "pullrequest:fulfilled"
18+
PullRequestDeclinedEvent string = "pullrequest:rejected"
19+
PullRequestCommentCreatedEvent string = "pullrequest:comment_created"
20+
PullRequestCommentUpdatedEvent string = "pullrequest:comment_updated"
21+
PullRequestCommentDeletedEvent string = "pullrequest:comment_deleted"
22+
)

0 commit comments

Comments
 (0)