aboutsummaryrefslogtreecommitdiffstats
path: root/services/webhook/webhook_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-10 13:13:16 +0800
committerGitHub <noreply@github.com>2021-11-10 13:13:16 +0800
commit33fca2b537d36cf998dd27425b2bb8ed5b0965f3 (patch)
tree817f392502e1c176a5cd7e80290520cb940a8416 /services/webhook/webhook_test.go
parentedbaa5d3f05b5ca397524587ba9db15edd61bc29 (diff)
downloadgitea-33fca2b537d36cf998dd27425b2bb8ed5b0965f3.tar.gz
gitea-33fca2b537d36cf998dd27425b2bb8ed5b0965f3.zip
Move webhook into models/webhook/ (#17579)
Diffstat (limited to 'services/webhook/webhook_test.go')
-rw-r--r--services/webhook/webhook_test.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/services/webhook/webhook_test.go b/services/webhook/webhook_test.go
index 095b30713c..75f19e50ce 100644
--- a/services/webhook/webhook_test.go
+++ b/services/webhook/webhook_test.go
@@ -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)