mirror of https://github.com/go-gitea/gitea
Git with a cup of tea, painless self-hosted git service
Mirror for internal git.with.parts use
https://git.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
973 B
37 lines
973 B
// Copyright 2017 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package webhook
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"code.gitea.io/gitea/models/db"
|
|
"code.gitea.io/gitea/models/unittest"
|
|
"code.gitea.io/gitea/modules/optional"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetSystemOrDefaultWebhooks(t *testing.T) {
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
hooks, err := GetSystemOrDefaultWebhooks(db.DefaultContext, optional.None[bool]())
|
|
assert.NoError(t, err)
|
|
if assert.Len(t, hooks, 2) {
|
|
assert.Equal(t, int64(5), hooks[0].ID)
|
|
assert.Equal(t, int64(6), hooks[1].ID)
|
|
}
|
|
|
|
hooks, err = GetSystemOrDefaultWebhooks(db.DefaultContext, optional.Some(true))
|
|
assert.NoError(t, err)
|
|
if assert.Len(t, hooks, 1) {
|
|
assert.Equal(t, int64(5), hooks[0].ID)
|
|
}
|
|
|
|
hooks, err = GetSystemOrDefaultWebhooks(db.DefaultContext, optional.Some(false))
|
|
assert.NoError(t, err)
|
|
if assert.Len(t, hooks, 1) {
|
|
assert.Equal(t, int64(6), hooks[0].ID)
|
|
}
|
|
}
|
|
|