mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 03:18:24 +00: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,7 +9,7 @@ import ( | ||||
|  | ||||
| 	"code.gitea.io/gitea/models/unittest" | ||||
| 	"code.gitea.io/gitea/models/webhook" | ||||
| 	"code.gitea.io/gitea/modules/test" | ||||
| 	"code.gitea.io/gitea/modules/contexttest" | ||||
|  | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| ) | ||||
| @@ -17,11 +17,11 @@ import ( | ||||
| func TestTestHook(t *testing.T) { | ||||
| 	unittest.PrepareTestEnv(t) | ||||
|  | ||||
| 	ctx, _ := test.MockAPIContext(t, "user2/repo1/wiki/_pages") | ||||
| 	ctx, _ := contexttest.MockAPIContext(t, "user2/repo1/wiki/_pages") | ||||
| 	ctx.SetParams(":id", "1") | ||||
| 	test.LoadRepo(t, ctx, 1) | ||||
| 	test.LoadRepoCommit(t, ctx) | ||||
| 	test.LoadUser(t, ctx, 2) | ||||
| 	contexttest.LoadRepo(t, ctx, 1) | ||||
| 	contexttest.LoadRepoCommit(t, ctx) | ||||
| 	contexttest.LoadUser(t, ctx, 2) | ||||
| 	TestHook(ctx) | ||||
| 	assert.EqualValues(t, http.StatusNoContent, ctx.Resp.Status()) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user