mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Move web/api context related testing function into a separate package (#26859)
Just like `models/unittest`, the testing helper functions should be in a separate package: `contexttest` And complete the TODO: > // TODO: move this function to other packages, because it depends on "models" package
This commit is contained in:
		@@ -9,8 +9,8 @@ import (
 | 
			
		||||
 | 
			
		||||
	repo_model "code.gitea.io/gitea/models/repo"
 | 
			
		||||
	"code.gitea.io/gitea/models/unittest"
 | 
			
		||||
	"code.gitea.io/gitea/modules/contexttest"
 | 
			
		||||
	api "code.gitea.io/gitea/modules/structs"
 | 
			
		||||
	"code.gitea.io/gitea/modules/test"
 | 
			
		||||
	"code.gitea.io/gitea/modules/web"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
@@ -19,9 +19,9 @@ import (
 | 
			
		||||
func TestRepoEdit(t *testing.T) {
 | 
			
		||||
	unittest.PrepareTestEnv(t)
 | 
			
		||||
 | 
			
		||||
	ctx, _ := test.MockAPIContext(t, "user2/repo1")
 | 
			
		||||
	test.LoadRepo(t, ctx, 1)
 | 
			
		||||
	test.LoadUser(t, ctx, 2)
 | 
			
		||||
	ctx, _ := contexttest.MockAPIContext(t, "user2/repo1")
 | 
			
		||||
	contexttest.LoadRepo(t, ctx, 1)
 | 
			
		||||
	contexttest.LoadUser(t, ctx, 2)
 | 
			
		||||
	ctx.Repo.Owner = ctx.Doer
 | 
			
		||||
	description := "new description"
 | 
			
		||||
	website := "http://wwww.newwebsite.com"
 | 
			
		||||
@@ -65,9 +65,9 @@ func TestRepoEdit(t *testing.T) {
 | 
			
		||||
func TestRepoEditNameChange(t *testing.T) {
 | 
			
		||||
	unittest.PrepareTestEnv(t)
 | 
			
		||||
 | 
			
		||||
	ctx, _ := test.MockAPIContext(t, "user2/repo1")
 | 
			
		||||
	test.LoadRepo(t, ctx, 1)
 | 
			
		||||
	test.LoadUser(t, ctx, 2)
 | 
			
		||||
	ctx, _ := contexttest.MockAPIContext(t, "user2/repo1")
 | 
			
		||||
	contexttest.LoadRepo(t, ctx, 1)
 | 
			
		||||
	contexttest.LoadUser(t, ctx, 2)
 | 
			
		||||
	ctx.Repo.Owner = ctx.Doer
 | 
			
		||||
	name := "newname"
 | 
			
		||||
	opts := api.EditRepoOption{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user