diff options
Diffstat (limited to 'modules/test')
-rw-r--r-- | modules/test/context_tests.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/test/context_tests.go b/modules/test/context_tests.go index 887446d716..aa109aa0d0 100644 --- a/modules/test/context_tests.go +++ b/modules/test/context_tests.go @@ -9,6 +9,7 @@ import ( "net/url" "testing" + "code.gitea.io/git" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" @@ -51,6 +52,15 @@ func LoadUser(t *testing.T, ctx *context.Context, userID int64) { ctx.User = models.AssertExistsAndLoadBean(t, &models.User{ID: userID}).(*models.User) } +// LoadGitRepo load a git repo into a test context. Requires that ctx.Repo has +// already been populated. +func LoadGitRepo(t *testing.T, ctx *context.Context) { + assert.NoError(t, ctx.Repo.Repository.GetOwner()) + var err error + ctx.Repo.GitRepo, err = git.OpenRepository(ctx.Repo.Repository.RepoPath()) + assert.NoError(t, err) +} + type mockLocale struct{} func (l mockLocale) Language() string { |