mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Move db related basic functions to models/db (#17075)
* Move db related basic functions to models/db * Fix lint * Fix lint * Fix test * Fix lint * Fix lint * revert unnecessary change * Fix test * Fix wrong replace string * Use *Context * Correct committer spelling and fix wrong replaced words Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
@@ -73,7 +74,7 @@ func assertPagesMetas(t *testing.T, expectedNames []string, metas interface{}) {
|
||||
}
|
||||
|
||||
func TestWiki(t *testing.T) {
|
||||
models.PrepareTestEnv(t)
|
||||
db.PrepareTestEnv(t)
|
||||
|
||||
ctx := test.MockContext(t, "user2/repo1/wiki/_pages")
|
||||
ctx.SetParams(":page", "Home")
|
||||
@@ -85,7 +86,7 @@ func TestWiki(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWikiPages(t *testing.T) {
|
||||
models.PrepareTestEnv(t)
|
||||
db.PrepareTestEnv(t)
|
||||
|
||||
ctx := test.MockContext(t, "user2/repo1/wiki/_pages")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
@@ -95,7 +96,7 @@ func TestWikiPages(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewWiki(t *testing.T) {
|
||||
models.PrepareTestEnv(t)
|
||||
db.PrepareTestEnv(t)
|
||||
|
||||
ctx := test.MockContext(t, "user2/repo1/wiki/_new")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
@@ -110,7 +111,7 @@ func TestNewWikiPost(t *testing.T) {
|
||||
"New page",
|
||||
"&&&&",
|
||||
} {
|
||||
models.PrepareTestEnv(t)
|
||||
db.PrepareTestEnv(t)
|
||||
|
||||
ctx := test.MockContext(t, "user2/repo1/wiki/_new")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
@@ -128,7 +129,7 @@ func TestNewWikiPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewWikiPost_ReservedName(t *testing.T) {
|
||||
models.PrepareTestEnv(t)
|
||||
db.PrepareTestEnv(t)
|
||||
|
||||
ctx := test.MockContext(t, "user2/repo1/wiki/_new")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
@@ -145,7 +146,7 @@ func TestNewWikiPost_ReservedName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEditWiki(t *testing.T) {
|
||||
models.PrepareTestEnv(t)
|
||||
db.PrepareTestEnv(t)
|
||||
|
||||
ctx := test.MockContext(t, "user2/repo1/wiki/_edit/Home")
|
||||
ctx.SetParams(":page", "Home")
|
||||
@@ -162,7 +163,7 @@ func TestEditWikiPost(t *testing.T) {
|
||||
"Home",
|
||||
"New/<page>",
|
||||
} {
|
||||
models.PrepareTestEnv(t)
|
||||
db.PrepareTestEnv(t)
|
||||
ctx := test.MockContext(t, "user2/repo1/wiki/_new/Home")
|
||||
ctx.SetParams(":page", "Home")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
@@ -183,7 +184,7 @@ func TestEditWikiPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteWikiPagePost(t *testing.T) {
|
||||
models.PrepareTestEnv(t)
|
||||
db.PrepareTestEnv(t)
|
||||
|
||||
ctx := test.MockContext(t, "user2/repo1/wiki/Home/delete")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
@@ -202,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",
|
||||
} {
|
||||
models.PrepareTestEnv(t)
|
||||
db.PrepareTestEnv(t)
|
||||
|
||||
ctx := test.MockContext(t, "user2/repo1/wiki/raw/"+filepath)
|
||||
ctx.SetParams("*", filepath)
|
||||
|
Reference in New Issue
Block a user