summaryrefslogtreecommitdiffstats
path: root/modules/test
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2017-12-07 21:22:02 -0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-12-08 13:22:02 +0800
commit596308f21328c2b9849e9192bce7b060f3c68fbf (patch)
tree479dfe11304f14d6ff05ca624d622ea2d127b347 /modules/test
parent68179dc67695def5fd7400bed1231e4bc0d2cc09 (diff)
downloadgitea-596308f21328c2b9849e9192bce7b060f3c68fbf.tar.gz
gitea-596308f21328c2b9849e9192bce7b060f3c68fbf.zip
Fix missing branch in release bug (#3108)
Diffstat (limited to 'modules/test')
-rw-r--r--modules/test/context_tests.go10
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 {