mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-03 00:44:35 -04:00
Move webhook to a standalone package under modules (#8747)
* Move webhook to a standalone package under modules * fix test * fix comments
This commit is contained in:
parent
ba336f6f45
commit
0e7f7df3cf
20 changed files with 570 additions and 478 deletions
|
@ -253,57 +253,3 @@ func TestUpdateHookTask(t *testing.T) {
|
|||
assert.NoError(t, UpdateHookTask(hook))
|
||||
AssertExistsAndLoadBean(t, hook)
|
||||
}
|
||||
|
||||
func TestPrepareWebhooks(t *testing.T) {
|
||||
assert.NoError(t, PrepareTestDatabase())
|
||||
|
||||
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
|
||||
hookTasks := []*HookTask{
|
||||
{RepoID: repo.ID, HookID: 1, EventType: HookEventPush},
|
||||
}
|
||||
for _, hookTask := range hookTasks {
|
||||
AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
assert.NoError(t, PrepareWebhooks(repo, HookEventPush, &api.PushPayload{}))
|
||||
for _, hookTask := range hookTasks {
|
||||
AssertExistsAndLoadBean(t, hookTask)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrepareWebhooksBranchFilterMatch(t *testing.T) {
|
||||
assert.NoError(t, PrepareTestDatabase())
|
||||
|
||||
repo := AssertExistsAndLoadBean(t, &Repository{ID: 2}).(*Repository)
|
||||
hookTasks := []*HookTask{
|
||||
{RepoID: repo.ID, HookID: 4, EventType: HookEventPush},
|
||||
}
|
||||
for _, hookTask := range hookTasks {
|
||||
AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
// this test also ensures that * doesn't handle / in any special way (like shell would)
|
||||
assert.NoError(t, PrepareWebhooks(repo, HookEventPush, &api.PushPayload{Ref: "refs/heads/feature/7791"}))
|
||||
for _, hookTask := range hookTasks {
|
||||
AssertExistsAndLoadBean(t, hookTask)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrepareWebhooksBranchFilterNoMatch(t *testing.T) {
|
||||
assert.NoError(t, PrepareTestDatabase())
|
||||
|
||||
repo := AssertExistsAndLoadBean(t, &Repository{ID: 2}).(*Repository)
|
||||
hookTasks := []*HookTask{
|
||||
{RepoID: repo.ID, HookID: 4, EventType: HookEventPush},
|
||||
}
|
||||
for _, hookTask := range hookTasks {
|
||||
AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
assert.NoError(t, PrepareWebhooks(repo, HookEventPush, &api.PushPayload{Ref: "refs/heads/fix_weird_bug"}))
|
||||
|
||||
for _, hookTask := range hookTasks {
|
||||
AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO TestHookTask_deliver
|
||||
|
||||
// TODO TestDeliverHooks
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue