mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-15 14:32:42 +00:00
Decouple unit test, remove intermediate unittestbridge
package (#17662)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
23bd7b1211
commit
81926d61db
151 changed files with 1719 additions and 1781 deletions
|
@ -8,7 +8,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
webhook_model "code.gitea.io/gitea/models/webhook"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
|
@ -30,50 +29,50 @@ func TestWebhook_GetSlackHook(t *testing.T) {
|
|||
func TestPrepareWebhooks(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
hookTasks := []*webhook_model.HookTask{
|
||||
{RepoID: repo.ID, HookID: 1, EventType: webhook_model.HookEventPush},
|
||||
}
|
||||
for _, hookTask := range hookTasks {
|
||||
db.AssertNotExistsBean(t, hookTask)
|
||||
unittest.AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
assert.NoError(t, PrepareWebhooks(repo, webhook_model.HookEventPush, &api.PushPayload{Commits: []*api.PayloadCommit{{}}}))
|
||||
for _, hookTask := range hookTasks {
|
||||
db.AssertExistsAndLoadBean(t, hookTask)
|
||||
unittest.AssertExistsAndLoadBean(t, hookTask)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrepareWebhooksBranchFilterMatch(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||
hookTasks := []*webhook_model.HookTask{
|
||||
{RepoID: repo.ID, HookID: 4, EventType: webhook_model.HookEventPush},
|
||||
}
|
||||
for _, hookTask := range hookTasks {
|
||||
db.AssertNotExistsBean(t, hookTask)
|
||||
unittest.AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
// this test also ensures that * doesn't handle / in any special way (like shell would)
|
||||
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)
|
||||
unittest.AssertExistsAndLoadBean(t, hookTask)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrepareWebhooksBranchFilterNoMatch(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||
hookTasks := []*webhook_model.HookTask{
|
||||
{RepoID: repo.ID, HookID: 4, EventType: webhook_model.HookEventPush},
|
||||
}
|
||||
for _, hookTask := range hookTasks {
|
||||
db.AssertNotExistsBean(t, hookTask)
|
||||
unittest.AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
assert.NoError(t, PrepareWebhooks(repo, webhook_model.HookEventPush, &api.PushPayload{Ref: "refs/heads/fix_weird_bug"}))
|
||||
|
||||
for _, hookTask := range hookTasks {
|
||||
db.AssertNotExistsBean(t, hookTask)
|
||||
unittest.AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue