1
0
Fork 0
forked from forgejo/forgejo

Decouple unit test code from business code (#17623)

This commit is contained in:
wxiaoguang 2021-11-12 22:36:47 +08:00 committed by GitHub
parent 7f802631c5
commit df64fa4865
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
136 changed files with 1058 additions and 830 deletions

View file

@ -10,7 +10,7 @@ import (
"testing"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/test"
"code.gitea.io/gitea/modules/web"
@ -74,7 +74,7 @@ func assertPagesMetas(t *testing.T, expectedNames []string, metas interface{}) {
}
func TestWiki(t *testing.T) {
db.PrepareTestEnv(t)
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/wiki/_pages")
ctx.SetParams(":page", "Home")
@ -86,7 +86,7 @@ func TestWiki(t *testing.T) {
}
func TestWikiPages(t *testing.T) {
db.PrepareTestEnv(t)
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/wiki/_pages")
test.LoadRepo(t, ctx, 1)
@ -96,7 +96,7 @@ func TestWikiPages(t *testing.T) {
}
func TestNewWiki(t *testing.T) {
db.PrepareTestEnv(t)
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/wiki/_new")
test.LoadUser(t, ctx, 2)
@ -111,7 +111,7 @@ func TestNewWikiPost(t *testing.T) {
"New page",
"&&&&",
} {
db.PrepareTestEnv(t)
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/wiki/_new")
test.LoadUser(t, ctx, 2)
@ -129,7 +129,7 @@ func TestNewWikiPost(t *testing.T) {
}
func TestNewWikiPost_ReservedName(t *testing.T) {
db.PrepareTestEnv(t)
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/wiki/_new")
test.LoadUser(t, ctx, 2)
@ -146,7 +146,7 @@ func TestNewWikiPost_ReservedName(t *testing.T) {
}
func TestEditWiki(t *testing.T) {
db.PrepareTestEnv(t)
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/wiki/_edit/Home")
ctx.SetParams(":page", "Home")
@ -163,7 +163,7 @@ func TestEditWikiPost(t *testing.T) {
"Home",
"New/<page>",
} {
db.PrepareTestEnv(t)
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/wiki/_new/Home")
ctx.SetParams(":page", "Home")
test.LoadUser(t, ctx, 2)
@ -184,7 +184,7 @@ func TestEditWikiPost(t *testing.T) {
}
func TestDeleteWikiPagePost(t *testing.T) {
db.PrepareTestEnv(t)
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/wiki/Home/delete")
test.LoadUser(t, ctx, 2)
@ -203,7 +203,7 @@ func TestWikiRaw(t *testing.T) {
"Page With Spaced Name.md": "text/plain; charset=utf-8",
"Page-With-Spaced-Name.md": "text/plain; charset=utf-8",
} {
db.PrepareTestEnv(t)
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/wiki/raw/"+filepath)
ctx.SetParams("*", filepath)