aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2021-11-12 22:36:47 +0800
committerGitHub <noreply@github.com>2021-11-12 22:36:47 +0800
commitdf64fa486555de6f403a795fd16c2e9e1d59e535 (patch)
treeb899e9b9e5d57409b1bf0e3afbd606b6a3900235 /routers
parent7f802631c54d2e91301158380b273b872d62bd80 (diff)
downloadgitea-df64fa486555de6f403a795fd16c2e9e1d59e535.tar.gz
gitea-df64fa486555de6f403a795fd16c2e9e1d59e535.zip
Decouple unit test code from business code (#17623)
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/hook_test.go3
-rw-r--r--routers/api/v1/repo/main_test.go4
-rw-r--r--routers/api/v1/repo/repo_test.go5
-rw-r--r--routers/web/admin/main_test.go4
-rw-r--r--routers/web/admin/users_test.go11
-rw-r--r--routers/web/repo/editor_test.go8
-rw-r--r--routers/web/repo/issue_label_test.go15
-rw-r--r--routers/web/repo/main_test.go4
-rw-r--r--routers/web/repo/projects_test.go4
-rw-r--r--routers/web/repo/release_test.go3
-rw-r--r--routers/web/repo/settings_test.go23
-rw-r--r--routers/web/repo/wiki_test.go20
-rw-r--r--routers/web/user/home_test.go12
-rw-r--r--routers/web/user/main_test.go4
-rw-r--r--routers/web/user/oauth_test.go3
-rw-r--r--routers/web/user/setting/account_test.go4
-rw-r--r--routers/web/user/setting/main_test.go4
17 files changed, 69 insertions, 62 deletions
diff --git a/routers/api/v1/repo/hook_test.go b/routers/api/v1/repo/hook_test.go
index 60fa6cead3..ff0aaf2938 100644
--- a/routers/api/v1/repo/hook_test.go
+++ b/routers/api/v1/repo/hook_test.go
@@ -9,6 +9,7 @@ import (
"testing"
"code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/models/webhook"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/test"
@@ -17,7 +18,7 @@ import (
)
func TestTestHook(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/wiki/_pages")
ctx.SetParams(":id", "1")
diff --git a/routers/api/v1/repo/main_test.go b/routers/api/v1/repo/main_test.go
index 7a66370e05..f9ed886999 100644
--- a/routers/api/v1/repo/main_test.go
+++ b/routers/api/v1/repo/main_test.go
@@ -8,9 +8,9 @@ import (
"path/filepath"
"testing"
- "code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
)
func TestMain(m *testing.M) {
- db.MainTest(m, filepath.Join("..", "..", "..", ".."))
+ unittest.MainTest(m, filepath.Join("..", "..", "..", ".."))
}
diff --git a/routers/api/v1/repo/repo_test.go b/routers/api/v1/repo/repo_test.go
index e4fd4f9424..b992b93fd4 100644
--- a/routers/api/v1/repo/repo_test.go
+++ b/routers/api/v1/repo/repo_test.go
@@ -10,6 +10,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/context"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/test"
@@ -19,7 +20,7 @@ import (
)
func TestRepoEdit(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1")
test.LoadRepo(t, ctx, 1)
@@ -66,7 +67,7 @@ func TestRepoEdit(t *testing.T) {
}
func TestRepoEditNameChange(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1")
test.LoadRepo(t, ctx, 1)
diff --git a/routers/web/admin/main_test.go b/routers/web/admin/main_test.go
index cfdefdb1b4..e41d8fea75 100644
--- a/routers/web/admin/main_test.go
+++ b/routers/web/admin/main_test.go
@@ -8,9 +8,9 @@ import (
"path/filepath"
"testing"
- "code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
)
func TestMain(m *testing.M) {
- db.MainTest(m, filepath.Join("..", "..", ".."))
+ unittest.MainTest(m, filepath.Join("..", "..", ".."))
}
diff --git a/routers/web/admin/users_test.go b/routers/web/admin/users_test.go
index 022d8f662c..62b35ea286 100644
--- a/routers/web/admin/users_test.go
+++ b/routers/web/admin/users_test.go
@@ -9,6 +9,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/test"
@@ -20,7 +21,7 @@ import (
func TestNewUserPost_MustChangePassword(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "admin/users/new")
u := db.AssertExistsAndLoadBean(t, &models.User{
@@ -57,7 +58,7 @@ func TestNewUserPost_MustChangePassword(t *testing.T) {
}
func TestNewUserPost_MustChangePasswordFalse(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "admin/users/new")
u := db.AssertExistsAndLoadBean(t, &models.User{
@@ -94,7 +95,7 @@ func TestNewUserPost_MustChangePasswordFalse(t *testing.T) {
}
func TestNewUserPost_InvalidEmail(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "admin/users/new")
u := db.AssertExistsAndLoadBean(t, &models.User{
@@ -124,7 +125,7 @@ func TestNewUserPost_InvalidEmail(t *testing.T) {
}
func TestNewUserPost_VisibilityDefaultPublic(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "admin/users/new")
u := db.AssertExistsAndLoadBean(t, &models.User{
@@ -162,7 +163,7 @@ func TestNewUserPost_VisibilityDefaultPublic(t *testing.T) {
}
func TestNewUserPost_VisibilityPrivate(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "admin/users/new")
u := db.AssertExistsAndLoadBean(t, &models.User{
diff --git a/routers/web/repo/editor_test.go b/routers/web/repo/editor_test.go
index 8ab1fe1ee8..77f94ff550 100644
--- a/routers/web/repo/editor_test.go
+++ b/routers/web/repo/editor_test.go
@@ -7,7 +7,7 @@ package repo
import (
"testing"
- "code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/test"
@@ -15,7 +15,7 @@ import (
)
func TestCleanUploadName(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
var kases = map[string]string{
".git/refs/master": "",
@@ -41,7 +41,7 @@ func TestCleanUploadName(t *testing.T) {
}
func TestGetUniquePatchBranchName(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1")
ctx.SetParams(":id", "1")
test.LoadRepo(t, ctx, 1)
@@ -56,7 +56,7 @@ func TestGetUniquePatchBranchName(t *testing.T) {
}
func TestGetClosestParentWithFiles(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1")
ctx.SetParams(":id", "1")
test.LoadRepo(t, ctx, 1)
diff --git a/routers/web/repo/issue_label_test.go b/routers/web/repo/issue_label_test.go
index 8c3caabe17..98fa9eb968 100644
--- a/routers/web/repo/issue_label_test.go
+++ b/routers/web/repo/issue_label_test.go
@@ -11,6 +11,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/test"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/services/forms"
@@ -30,7 +31,7 @@ func int64SliceToCommaSeparated(a []int64) string {
}
func TestInitializeLabels(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/labels/initialize")
test.LoadUser(t, ctx, 2)
test.LoadRepo(t, ctx, 2)
@@ -46,7 +47,7 @@ func TestInitializeLabels(t *testing.T) {
}
func TestRetrieveLabels(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
for _, testCase := range []struct {
RepoID int64
Sort string
@@ -73,7 +74,7 @@ func TestRetrieveLabels(t *testing.T) {
}
func TestNewLabel(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/labels/edit")
test.LoadUser(t, ctx, 2)
test.LoadRepo(t, ctx, 1)
@@ -91,7 +92,7 @@ func TestNewLabel(t *testing.T) {
}
func TestUpdateLabel(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/labels/edit")
test.LoadUser(t, ctx, 2)
test.LoadRepo(t, ctx, 1)
@@ -111,7 +112,7 @@ func TestUpdateLabel(t *testing.T) {
}
func TestDeleteLabel(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/labels/delete")
test.LoadUser(t, ctx, 2)
test.LoadRepo(t, ctx, 1)
@@ -124,7 +125,7 @@ func TestDeleteLabel(t *testing.T) {
}
func TestUpdateIssueLabel_Clear(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
test.LoadRepo(t, ctx, 1)
@@ -149,7 +150,7 @@ func TestUpdateIssueLabel_Toggle(t *testing.T) {
{"toggle", []int64{1, 3}, 1, false},
{"toggle", []int64{1, 2}, 2, true},
} {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
test.LoadRepo(t, ctx, 1)
diff --git a/routers/web/repo/main_test.go b/routers/web/repo/main_test.go
index 8322567249..81e3a8e281 100644
--- a/routers/web/repo/main_test.go
+++ b/routers/web/repo/main_test.go
@@ -8,9 +8,9 @@ import (
"path/filepath"
"testing"
- "code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
)
func TestMain(m *testing.M) {
- db.MainTest(m, filepath.Join("..", "..", ".."))
+ unittest.MainTest(m, filepath.Join("..", "..", ".."))
}
diff --git a/routers/web/repo/projects_test.go b/routers/web/repo/projects_test.go
index d3b78cc775..62fb045740 100644
--- a/routers/web/repo/projects_test.go
+++ b/routers/web/repo/projects_test.go
@@ -7,14 +7,14 @@ package repo
import (
"testing"
- "code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/test"
"github.com/stretchr/testify/assert"
)
func TestCheckProjectBoardChangePermissions(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/projects/1/2")
test.LoadUser(t, ctx, 2)
test.LoadRepo(t, ctx, 1)
diff --git a/routers/web/repo/release_test.go b/routers/web/repo/release_test.go
index 7ac49c012f..ff54232da7 100644
--- a/routers/web/repo/release_test.go
+++ b/routers/web/repo/release_test.go
@@ -9,6 +9,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/test"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/services/forms"
@@ -44,7 +45,7 @@ func TestNewReleasePost(t *testing.T) {
},
},
} {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/releases/new")
test.LoadUser(t, ctx, 2)
diff --git a/routers/web/repo/settings_test.go b/routers/web/repo/settings_test.go
index a3ed271cce..78426f5b79 100644
--- a/routers/web/repo/settings_test.go
+++ b/routers/web/repo/settings_test.go
@@ -11,6 +11,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/test"
@@ -43,7 +44,7 @@ func TestAddReadOnlyDeployKey(t *testing.T) {
} else {
return
}
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/settings/keys")
@@ -72,7 +73,7 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) {
return
}
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/settings/keys")
@@ -97,7 +98,7 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) {
func TestCollaborationPost(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
test.LoadUser(t, ctx, 4)
@@ -133,7 +134,7 @@ func TestCollaborationPost(t *testing.T) {
func TestCollaborationPost_InactiveUser(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
test.LoadUser(t, ctx, 9)
@@ -157,7 +158,7 @@ func TestCollaborationPost_InactiveUser(t *testing.T) {
func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
test.LoadUser(t, ctx, 4)
@@ -199,7 +200,7 @@ func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
func TestCollaborationPost_NonExistentUser(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
test.LoadRepo(t, ctx, 1)
@@ -221,7 +222,7 @@ func TestCollaborationPost_NonExistentUser(t *testing.T) {
}
func TestAddTeamPost(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "org26/repo43")
ctx.Req.Form.Set("team", "team11")
@@ -261,7 +262,7 @@ func TestAddTeamPost(t *testing.T) {
}
func TestAddTeamPost_NotAllowed(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "org26/repo43")
ctx.Req.Form.Set("team", "team11")
@@ -302,7 +303,7 @@ func TestAddTeamPost_NotAllowed(t *testing.T) {
}
func TestAddTeamPost_AddTeamTwice(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "org26/repo43")
ctx.Req.Form.Set("team", "team11")
@@ -343,7 +344,7 @@ func TestAddTeamPost_AddTeamTwice(t *testing.T) {
}
func TestAddTeamPost_NonExistentTeam(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "org26/repo43")
ctx.Req.Form.Set("team", "team-non-existent")
@@ -376,7 +377,7 @@ func TestAddTeamPost_NonExistentTeam(t *testing.T) {
}
func TestDeleteTeam(t *testing.T) {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "org3/team1/repo3")
ctx.Req.Form.Set("id", "2")
diff --git a/routers/web/repo/wiki_test.go b/routers/web/repo/wiki_test.go
index 14cb893d46..cf49f19afe 100644
--- a/routers/web/repo/wiki_test.go
+++ b/routers/web/repo/wiki_test.go
@@ -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)
diff --git a/routers/web/user/home_test.go b/routers/web/user/home_test.go
index daf473b270..cd599abd04 100644
--- a/routers/web/user/home_test.go
+++ b/routers/web/user/home_test.go
@@ -9,7 +9,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/setting"
"code.gitea.io/gitea/modules/test"
@@ -19,7 +19,7 @@ import (
func TestArchivedIssues(t *testing.T) {
// Arrange
setting.UI.IssuePagingNum = 1
- assert.NoError(t, db.LoadFixtures())
+ assert.NoError(t, unittest.LoadFixtures())
ctx := test.MockContext(t, "issues")
test.LoadUser(t, ctx, 30)
@@ -52,7 +52,7 @@ func TestArchivedIssues(t *testing.T) {
func TestIssues(t *testing.T) {
setting.UI.IssuePagingNum = 1
- assert.NoError(t, db.LoadFixtures())
+ assert.NoError(t, unittest.LoadFixtures())
ctx := test.MockContext(t, "issues")
test.LoadUser(t, ctx, 2)
@@ -68,7 +68,7 @@ func TestIssues(t *testing.T) {
func TestPulls(t *testing.T) {
setting.UI.IssuePagingNum = 20
- assert.NoError(t, db.LoadFixtures())
+ assert.NoError(t, unittest.LoadFixtures())
ctx := test.MockContext(t, "pulls")
test.LoadUser(t, ctx, 2)
@@ -81,7 +81,7 @@ func TestPulls(t *testing.T) {
func TestMilestones(t *testing.T) {
setting.UI.IssuePagingNum = 1
- assert.NoError(t, db.LoadFixtures())
+ assert.NoError(t, unittest.LoadFixtures())
ctx := test.MockContext(t, "milestones")
test.LoadUser(t, ctx, 2)
@@ -100,7 +100,7 @@ func TestMilestones(t *testing.T) {
func TestMilestonesForSpecificRepo(t *testing.T) {
setting.UI.IssuePagingNum = 1
- assert.NoError(t, db.LoadFixtures())
+ assert.NoError(t, unittest.LoadFixtures())
ctx := test.MockContext(t, "milestones")
test.LoadUser(t, ctx, 2)
diff --git a/routers/web/user/main_test.go b/routers/web/user/main_test.go
index 272e4b8b21..77b48d89fb 100644
--- a/routers/web/user/main_test.go
+++ b/routers/web/user/main_test.go
@@ -8,9 +8,9 @@ import (
"path/filepath"
"testing"
- "code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
)
func TestMain(m *testing.M) {
- db.MainTest(m, filepath.Join("..", "..", ".."))
+ unittest.MainTest(m, filepath.Join("..", "..", ".."))
}
diff --git a/routers/web/user/oauth_test.go b/routers/web/user/oauth_test.go
index 27d339b778..e0c1bf4e77 100644
--- a/routers/web/user/oauth_test.go
+++ b/routers/web/user/oauth_test.go
@@ -10,6 +10,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/login"
+ "code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/services/auth/source/oauth2"
"github.com/golang-jwt/jwt"
@@ -41,7 +42,7 @@ func createAndParseToken(t *testing.T, grant *login.OAuth2Grant) *oauth2.OIDCTok
}
func TestNewAccessTokenResponse_OIDCToken(t *testing.T) {
- assert.NoError(t, db.PrepareTestDatabase())
+ assert.NoError(t, unittest.PrepareTestDatabase())
grants, err := login.GetOAuth2GrantsByUserID(3)
assert.NoError(t, err)
diff --git a/routers/web/user/setting/account_test.go b/routers/web/user/setting/account_test.go
index bfb7ac4872..cd5c77795e 100644
--- a/routers/web/user/setting/account_test.go
+++ b/routers/web/user/setting/account_test.go
@@ -8,7 +8,7 @@ import (
"net/http"
"testing"
- "code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/test"
"code.gitea.io/gitea/modules/web"
@@ -81,7 +81,7 @@ func TestChangePassword(t *testing.T) {
PasswordComplexity: pcLU,
},
} {
- db.PrepareTestEnv(t)
+ unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user/settings/security")
test.LoadUser(t, ctx, 2)
test.LoadRepo(t, ctx, 1)
diff --git a/routers/web/user/setting/main_test.go b/routers/web/user/setting/main_test.go
index a0fbe55ee1..b6ed7f5b18 100644
--- a/routers/web/user/setting/main_test.go
+++ b/routers/web/user/setting/main_test.go
@@ -8,9 +8,9 @@ import (
"path/filepath"
"testing"
- "code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
)
func TestMain(m *testing.M) {
- db.MainTest(m, filepath.Join("..", "..", "..", ".."))
+ unittest.MainTest(m, filepath.Join("..", "..", "..", ".."))
}