mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Refactor AssertExistsAndLoadBean to use generics (#20797)
* Refactor AssertExistsAndLoadBean to use generics * Fix tests Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
		@@ -56,7 +56,7 @@ func MockContext(t *testing.T, path string) *context.Context {
 | 
			
		||||
// LoadRepo load a repo into a test context.
 | 
			
		||||
func LoadRepo(t *testing.T, ctx *context.Context, repoID int64) {
 | 
			
		||||
	ctx.Repo = &context.Repository{}
 | 
			
		||||
	ctx.Repo.Repository = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: repoID}).(*repo_model.Repository)
 | 
			
		||||
	ctx.Repo.Repository = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: repoID})
 | 
			
		||||
	var err error
 | 
			
		||||
	ctx.Repo.Owner, err = user_model.GetUserByID(ctx.Repo.Repository.OwnerID)
 | 
			
		||||
	assert.NoError(t, err)
 | 
			
		||||
@@ -81,7 +81,7 @@ func LoadRepoCommit(t *testing.T, ctx *context.Context) {
 | 
			
		||||
 | 
			
		||||
// LoadUser load a user into a test context.
 | 
			
		||||
func LoadUser(t *testing.T, ctx *context.Context, userID int64) {
 | 
			
		||||
	ctx.Doer = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID}).(*user_model.User)
 | 
			
		||||
	ctx.Doer = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// LoadGitRepo load a git repo into a test context. Requires that ctx.Repo has
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user