fix webhook fixtures

This commit is contained in:
oliverpool 2024-03-19 11:59:48 +01:00
parent 8750a5a42b
commit 2536c2db89
4 changed files with 59 additions and 23 deletions

View file

@ -28,10 +28,19 @@ func TestWebhook_GetSlackHook(t *testing.T) {
})
}
func activateWebhook(t *testing.T, hookID int64) {
t.Helper()
updated, err := db.GetEngine(db.DefaultContext).ID(hookID).Cols("is_active").Update(webhook_model.Webhook{IsActive: true})
assert.Equal(t, int64(1), updated)
assert.NoError(t, err)
}
func TestPrepareWebhooks(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
activateWebhook(t, 1)
hookTasks := []*webhook_model.HookTask{
{HookID: 1, EventType: webhook_module.HookEventPush},
}
@ -48,6 +57,8 @@ func TestPrepareWebhooksBranchFilterMatch(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
activateWebhook(t, 4)
hookTasks := []*webhook_model.HookTask{
{HookID: 4, EventType: webhook_module.HookEventPush},
}