From a4bfef265d9e512830350635a0489c2cdcd6508f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 19 Sep 2021 19:49:59 +0800 Subject: 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 --- routers/web/admin/users_test.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'routers/web/admin/users_test.go') diff --git a/routers/web/admin/users_test.go b/routers/web/admin/users_test.go index 3d0b11a774..022d8f662c 100644 --- a/routers/web/admin/users_test.go +++ b/routers/web/admin/users_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" @@ -19,10 +20,10 @@ import ( func TestNewUserPost_MustChangePassword(t *testing.T) { - models.PrepareTestEnv(t) + db.PrepareTestEnv(t) ctx := test.MockContext(t, "admin/users/new") - u := models.AssertExistsAndLoadBean(t, &models.User{ + u := db.AssertExistsAndLoadBean(t, &models.User{ IsAdmin: true, ID: 2, }).(*models.User) @@ -56,10 +57,10 @@ func TestNewUserPost_MustChangePassword(t *testing.T) { } func TestNewUserPost_MustChangePasswordFalse(t *testing.T) { - models.PrepareTestEnv(t) + db.PrepareTestEnv(t) ctx := test.MockContext(t, "admin/users/new") - u := models.AssertExistsAndLoadBean(t, &models.User{ + u := db.AssertExistsAndLoadBean(t, &models.User{ IsAdmin: true, ID: 2, }).(*models.User) @@ -93,10 +94,10 @@ func TestNewUserPost_MustChangePasswordFalse(t *testing.T) { } func TestNewUserPost_InvalidEmail(t *testing.T) { - models.PrepareTestEnv(t) + db.PrepareTestEnv(t) ctx := test.MockContext(t, "admin/users/new") - u := models.AssertExistsAndLoadBean(t, &models.User{ + u := db.AssertExistsAndLoadBean(t, &models.User{ IsAdmin: true, ID: 2, }).(*models.User) @@ -123,10 +124,10 @@ func TestNewUserPost_InvalidEmail(t *testing.T) { } func TestNewUserPost_VisibilityDefaultPublic(t *testing.T) { - models.PrepareTestEnv(t) + db.PrepareTestEnv(t) ctx := test.MockContext(t, "admin/users/new") - u := models.AssertExistsAndLoadBean(t, &models.User{ + u := db.AssertExistsAndLoadBean(t, &models.User{ IsAdmin: true, ID: 2, }).(*models.User) @@ -161,10 +162,10 @@ func TestNewUserPost_VisibilityDefaultPublic(t *testing.T) { } func TestNewUserPost_VisibilityPrivate(t *testing.T) { - models.PrepareTestEnv(t) + db.PrepareTestEnv(t) ctx := test.MockContext(t, "admin/users/new") - u := models.AssertExistsAndLoadBean(t, &models.User{ + u := db.AssertExistsAndLoadBean(t, &models.User{ IsAdmin: true, ID: 2, }).(*models.User) -- cgit v1.2.3