summaryrefslogtreecommitdiffstats
path: root/models/webhook
diff options
context:
space:
mode:
authorEarl Warren <earl-warren@noreply.codeberg.org>2024-03-24 08:28:31 +0100
committerEarl Warren <earl-warren@noreply.codeberg.org>2024-03-24 08:28:31 +0100
commit5a18b7463255e5d1aefdacaeae9b7d0459b34286 (patch)
treec26de5f74907a36df6ef1ee6228ff740d6ded9a6 /models/webhook
parentMerge pull request '[CI] backport: do no nothing if there are no backport lab... (diff)
parentdrop log.Error in ReadRepoNotifications (diff)
downloadforgejo-5a18b7463255e5d1aefdacaeae9b7d0459b34286.tar.xz
forgejo-5a18b7463255e5d1aefdacaeae9b7d0459b34286.zip
Merge pull request '[TESTS] fail when log.Error is called' (#2657) from oliverpool/forgejo:fail_test_on_log_error into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2657
Diffstat (limited to 'models/webhook')
-rw-r--r--models/webhook/webhook_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/models/webhook/webhook_test.go b/models/webhook/webhook_test.go
index f4403776ce..b4f6ffa189 100644
--- a/models/webhook/webhook_test.go
+++ b/models/webhook/webhook_test.go
@@ -124,6 +124,9 @@ func TestGetWebhookByOwnerID(t *testing.T) {
func TestGetActiveWebhooksByRepoID(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
+
+ activateWebhook(t, 1)
+
hooks, err := db.Find[Webhook](db.DefaultContext, ListWebhookOptions{RepoID: 1, IsActive: optional.Some(true)})
assert.NoError(t, err)
if assert.Len(t, hooks, 1) {
@@ -144,6 +147,9 @@ func TestGetWebhooksByRepoID(t *testing.T) {
func TestGetActiveWebhooksByOwnerID(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
+
+ activateWebhook(t, 3)
+
hooks, err := db.Find[Webhook](db.DefaultContext, ListWebhookOptions{OwnerID: 3, IsActive: optional.Some(true)})
assert.NoError(t, err)
if assert.Len(t, hooks, 1) {
@@ -152,8 +158,18 @@ func TestGetActiveWebhooksByOwnerID(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{IsActive: true})
+ assert.Equal(t, int64(1), updated)
+ assert.NoError(t, err)
+}
+
func TestGetWebhooksByOwnerID(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
+
+ activateWebhook(t, 3)
+
hooks, err := db.Find[Webhook](db.DefaultContext, ListWebhookOptions{OwnerID: 3})
assert.NoError(t, err)
if assert.Len(t, hooks, 1) {