Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Jan 21, 2025
1 parent 7e98626 commit 3847665
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
6 changes: 3 additions & 3 deletions models/webhook/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ func TestWebhook_UpdateEvent(t *testing.T) {
}

func TestWebhook_EventsArray(t *testing.T) {
assert.Equal(t, []string{
assert.EqualValues(t, []string{
"create", "delete", "fork", "push",
"issues", "issue_assign", "issue_label", "issue_milestone", "issue_comment",
"pull_request", "pull_request_assign", "pull_request_label", "pull_request_milestone",
"pull_request_comment", "pull_request_review_approved", "pull_request_review_rejected",
"pull_request_review_comment", "pull_request_sync", "wiki", "repository", "release",
"package", "pull_request_review_request",
"pull_request_review_comment", "pull_request_sync", "pull_request_review_request", "wiki", "repository", "release",
"package", "status",
},
(&Webhook{
HookEvent: &webhook_module.HookEvent{SendEverything: true},
Expand Down
7 changes: 3 additions & 4 deletions modules/webhook/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const (
HookEventPullRequestLabel HookEventType = "pull_request_label"
HookEventPullRequestMilestone HookEventType = "pull_request_milestone"
HookEventPullRequestComment HookEventType = "pull_request_comment"
HookEventPullRequestReview HookEventType = "pull_request_review"
HookEventPullRequestReviewApproved HookEventType = "pull_request_review_approved"
HookEventPullRequestReviewRejected HookEventType = "pull_request_review_rejected"
HookEventPullRequestReviewComment HookEventType = "pull_request_review_comment"
Expand All @@ -32,9 +31,11 @@ const (
HookEventRepository HookEventType = "repository"
HookEventRelease HookEventType = "release"
HookEventPackage HookEventType = "package"
HookEventSchedule HookEventType = "schedule"
HookEventStatus HookEventType = "status"
// once a new event added here, please also added to AllEvents() function

// Actions event only
HookEventSchedule HookEventType = "schedule"
)

func AllEvents() []HookEventType {
Expand All @@ -53,7 +54,6 @@ func AllEvents() []HookEventType {
HookEventPullRequestLabel,
HookEventPullRequestMilestone,
HookEventPullRequestComment,
HookEventPullRequestReview,
HookEventPullRequestReviewApproved,
HookEventPullRequestReviewRejected,
HookEventPullRequestReviewComment,
Expand All @@ -63,7 +63,6 @@ func AllEvents() []HookEventType {
HookEventRepository,
HookEventRelease,
HookEventPackage,
HookEventSchedule,
HookEventStatus,
}
}
Expand Down
2 changes: 0 additions & 2 deletions routers/api/v1/utils/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, ownerID, repoI
webhook_module.HookEventPullRequestLabel: pullHook(form.Events, string(webhook_module.HookEventPullRequestLabel)),
webhook_module.HookEventPullRequestMilestone: pullHook(form.Events, string(webhook_module.HookEventPullRequestMilestone)),
webhook_module.HookEventPullRequestComment: pullHook(form.Events, string(webhook_module.HookEventPullRequestComment)),
webhook_module.HookEventPullRequestReview: pullHook(form.Events, "pull_request_review"),
webhook_module.HookEventPullRequestReviewRequest: pullHook(form.Events, string(webhook_module.HookEventPullRequestReviewRequest)),
webhook_module.HookEventPullRequestSync: pullHook(form.Events, string(webhook_module.HookEventPullRequestSync)),
webhook_module.HookEventWiki: util.SliceContainsString(form.Events, string(webhook_module.HookEventWiki), true),
Expand Down Expand Up @@ -385,7 +384,6 @@ func editHook(ctx *context.APIContext, form *api.EditHookOption, w *webhook.Webh
w.HookEvents[webhook_module.HookEventPullRequestLabel] = pullHook(form.Events, string(webhook_module.HookEventPullRequestLabel))
w.HookEvents[webhook_module.HookEventPullRequestMilestone] = pullHook(form.Events, string(webhook_module.HookEventPullRequestMilestone))
w.HookEvents[webhook_module.HookEventPullRequestComment] = pullHook(form.Events, string(webhook_module.HookEventPullRequestComment))
w.HookEvents[webhook_module.HookEventPullRequestReview] = pullHook(form.Events, "pull_request_review")
w.HookEvents[webhook_module.HookEventPullRequestReviewRequest] = pullHook(form.Events, string(webhook_module.HookEventPullRequestReviewRequest))
w.HookEvents[webhook_module.HookEventPullRequestSync] = pullHook(form.Events, string(webhook_module.HookEventPullRequestSync))

Expand Down
1 change: 0 additions & 1 deletion routers/web/repo/setting/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ func ParseHookEvent(form forms.WebhookForm) *webhook_module.HookEvent {
webhook_module.HookEventPullRequestLabel: form.PullRequestLabel,
webhook_module.HookEventPullRequestMilestone: form.PullRequestMilestone,
webhook_module.HookEventPullRequestComment: form.PullRequestComment,
webhook_module.HookEventPullRequestReview: form.PullRequestReview,
webhook_module.HookEventPullRequestSync: form.PullRequestSync,
webhook_module.HookEventPullRequestReviewRequest: form.PullRequestReviewRequest,
webhook_module.HookEventWiki: form.Wiki,
Expand Down
1 change: 0 additions & 1 deletion services/forms/repo_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ type WebhookForm struct {
PullRequestLabel bool
PullRequestMilestone bool
PullRequestComment bool
PullRequestReview bool
PullRequestSync bool
PullRequestReviewRequest bool
Wiki bool
Expand Down

0 comments on commit 3847665

Please sign in to comment.