Add tests for webhook and fix some webhook bugs (#33396) (#33442)

This PR created a mock webhook server in the tests and added integration
tests for generic webhooks.
It also fixes bugs in package webhooks and pull request comment
webhooks.

This also corrected an error on the package webhook. The previous
implementation uses a `User` struct as an organization, now it has been
corrected but it will not be consistent with the previous
implementation, some fields which not belong to the organization have
been removed.

Backport #33396
Backport part of #33337
This commit is contained in:
Lunny Xiao 2025-02-01 22:44:50 -08:00 committed by GitHub
parent ebac324ff2
commit 23971a77a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 682 additions and 105 deletions

View file

@ -277,6 +277,10 @@ func newDiscordRequest(_ context.Context, w *webhook_model.Webhook, t *webhook_m
return newJSONRequest(pc, w, t, true)
}
func init() {
RegisterWebhookRequester(webhook_module.DISCORD, newDiscordRequest)
}
func parseHookPullRequestEventType(event webhook_module.HookEventType) (string, error) {
switch event {
case webhook_module.HookEventPullRequestReviewApproved: