mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-28 18:11:36 +00:00
models/webhook: use db.Insert in tests, merge fixture setup into prepareWebhookTestData
Agent-Logs-Url: https://github.com/go-gitea/gitea/sessions/d187e3a5-2c68-4115-a4d1-d2bda8f54004 Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
66e0e1e2c9
commit
8bb79e76fa
@@ -6,6 +6,7 @@ package webhook
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
@@ -44,7 +45,7 @@ func TestPrepareWebhooks(t *testing.T) {
|
||||
Events: `{"push_only":true}`,
|
||||
IsActive: true,
|
||||
}
|
||||
assert.NoError(t, webhook_model.CreateWebhook(t.Context(), hook))
|
||||
assert.NoError(t, db.Insert(t.Context(), hook))
|
||||
|
||||
hookTask := &webhook_model.HookTask{HookID: hook.ID, EventType: webhook_module.HookEventPush}
|
||||
unittest.AssertNotExistsBean(t, hookTask)
|
||||
@@ -63,7 +64,7 @@ func TestPrepareWebhooksBranchFilterMatch(t *testing.T) {
|
||||
Events: `{"push_only":true,"branch_filter":"{master,feature*}"}`,
|
||||
IsActive: true,
|
||||
}
|
||||
assert.NoError(t, webhook_model.CreateWebhook(t.Context(), hook))
|
||||
assert.NoError(t, db.Insert(t.Context(), hook))
|
||||
|
||||
hookTask := &webhook_model.HookTask{HookID: hook.ID, EventType: webhook_module.HookEventPush}
|
||||
unittest.AssertNotExistsBean(t, hookTask)
|
||||
@@ -83,7 +84,7 @@ func TestPrepareWebhooksBranchFilterNoMatch(t *testing.T) {
|
||||
Events: `{"push_only":true,"branch_filter":"{master,feature*}"}`,
|
||||
IsActive: true,
|
||||
}
|
||||
assert.NoError(t, webhook_model.CreateWebhook(t.Context(), hook))
|
||||
assert.NoError(t, db.Insert(t.Context(), hook))
|
||||
|
||||
hookTask := &webhook_model.HookTask{HookID: hook.ID, EventType: webhook_module.HookEventPush}
|
||||
unittest.AssertNotExistsBean(t, hookTask)
|
||||
|
||||
Reference in New Issue
Block a user