forked from forgejo/forgejo
Move webhook into models/webhook/ (#17579)
This commit is contained in:
parent
edbaa5d3f0
commit
33fca2b537
47 changed files with 770 additions and 717 deletions
|
@ -9,12 +9,13 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
webhook_model "code.gitea.io/gitea/models/webhook"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestWebhook_GetSlackHook(t *testing.T) {
|
||||
w := &models.Webhook{
|
||||
w := &webhook_model.Webhook{
|
||||
Meta: `{"channel": "foo", "username": "username", "color": "blue"}`,
|
||||
}
|
||||
slackHook := GetSlackHook(w)
|
||||
|
@ -29,13 +30,13 @@ func TestPrepareWebhooks(t *testing.T) {
|
|||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
hookTasks := []*models.HookTask{
|
||||
{RepoID: repo.ID, HookID: 1, EventType: models.HookEventPush},
|
||||
hookTasks := []*webhook_model.HookTask{
|
||||
{RepoID: repo.ID, HookID: 1, EventType: webhook_model.HookEventPush},
|
||||
}
|
||||
for _, hookTask := range hookTasks {
|
||||
db.AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
assert.NoError(t, PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{Commits: []*api.PayloadCommit{{}}}))
|
||||
assert.NoError(t, PrepareWebhooks(repo, webhook_model.HookEventPush, &api.PushPayload{Commits: []*api.PayloadCommit{{}}}))
|
||||
for _, hookTask := range hookTasks {
|
||||
db.AssertExistsAndLoadBean(t, hookTask)
|
||||
}
|
||||
|
@ -45,14 +46,14 @@ func TestPrepareWebhooksBranchFilterMatch(t *testing.T) {
|
|||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||
hookTasks := []*models.HookTask{
|
||||
{RepoID: repo.ID, HookID: 4, EventType: models.HookEventPush},
|
||||
hookTasks := []*webhook_model.HookTask{
|
||||
{RepoID: repo.ID, HookID: 4, EventType: webhook_model.HookEventPush},
|
||||
}
|
||||
for _, hookTask := range hookTasks {
|
||||
db.AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
// this test also ensures that * doesn't handle / in any special way (like shell would)
|
||||
assert.NoError(t, PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{Ref: "refs/heads/feature/7791", Commits: []*api.PayloadCommit{{}}}))
|
||||
assert.NoError(t, PrepareWebhooks(repo, webhook_model.HookEventPush, &api.PushPayload{Ref: "refs/heads/feature/7791", Commits: []*api.PayloadCommit{{}}}))
|
||||
for _, hookTask := range hookTasks {
|
||||
db.AssertExistsAndLoadBean(t, hookTask)
|
||||
}
|
||||
|
@ -62,13 +63,13 @@ func TestPrepareWebhooksBranchFilterNoMatch(t *testing.T) {
|
|||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||
hookTasks := []*models.HookTask{
|
||||
{RepoID: repo.ID, HookID: 4, EventType: models.HookEventPush},
|
||||
hookTasks := []*webhook_model.HookTask{
|
||||
{RepoID: repo.ID, HookID: 4, EventType: webhook_model.HookEventPush},
|
||||
}
|
||||
for _, hookTask := range hookTasks {
|
||||
db.AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
assert.NoError(t, PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{Ref: "refs/heads/fix_weird_bug"}))
|
||||
assert.NoError(t, PrepareWebhooks(repo, webhook_model.HookEventPush, &api.PushPayload{Ref: "refs/heads/fix_weird_bug"}))
|
||||
|
||||
for _, hookTask := range hookTasks {
|
||||
db.AssertNotExistsBean(t, hookTask)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue