aboutsummaryrefslogtreecommitdiffstats
path: root/services/contexttest/context_tests.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/contexttest/context_tests.go')
-rw-r--r--services/contexttest/context_tests.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/services/contexttest/context_tests.go b/services/contexttest/context_tests.go
index c895de3569..b54023897b 100644
--- a/services/contexttest/context_tests.go
+++ b/services/contexttest/context_tests.go
@@ -170,10 +170,19 @@ func LoadUser(t *testing.T, ctx gocontext.Context, userID int64) {
// 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.LoadOwner(ctx))
+func LoadGitRepo(t *testing.T, ctx gocontext.Context) {
+ var repo *context.Repository
+ switch ctx := any(ctx).(type) {
+ case *context.Context:
+ repo = ctx.Repo
+ case *context.APIContext:
+ repo = ctx.Repo
+ default:
+ assert.FailNow(t, "context is not *context.Context or *context.APIContext")
+ }
+ assert.NoError(t, repo.Repository.LoadOwner(ctx))
var err error
- ctx.Repo.GitRepo, err = gitrepo.OpenRepository(ctx, ctx.Repo.Repository)
+ repo.GitRepo, err = gitrepo.OpenRepository(ctx, repo.Repository)
assert.NoError(t, err)
}