summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-12-10 03:46:31 +0100
committerGitHub <noreply@github.com>2022-12-10 03:46:31 +0100
commit68704532c28cf09db96c988291b2f82c5e615984 (patch)
treec6537092dc11054f96b202fdb957755ed116cd99 /tests
parentChange ID pattern of raw content container for issue (#21966) (diff)
downloadforgejo-68704532c28cf09db96c988291b2f82c5e615984.tar.xz
forgejo-68704532c28cf09db96c988291b2f82c5e615984.zip
Rename almost all Ctx functions (#22071)
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/api_repo_edit_test.go11
-rw-r--r--tests/integration/mirror_pull_test.go7
2 files changed, 10 insertions, 8 deletions
diff --git a/tests/integration/api_repo_edit_test.go b/tests/integration/api_repo_edit_test.go
index 47e07f8d4b..716cebeb7c 100644
--- a/tests/integration/api_repo_edit_test.go
+++ b/tests/integration/api_repo_edit_test.go
@@ -9,6 +9,7 @@ import (
"net/url"
"testing"
+ "code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
unit_model "code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/models/unittest"
@@ -27,7 +28,7 @@ func getRepoEditOptionFromRepo(repo *repo_model.Repository) *api.EditRepoOption
hasIssues := false
var internalTracker *api.InternalTracker
var externalTracker *api.ExternalTracker
- if unit, err := repo.GetUnit(unit_model.TypeIssues); err == nil {
+ if unit, err := repo.GetUnit(db.DefaultContext, unit_model.TypeIssues); err == nil {
config := unit.IssuesConfig()
hasIssues = true
internalTracker = &api.InternalTracker{
@@ -35,7 +36,7 @@ func getRepoEditOptionFromRepo(repo *repo_model.Repository) *api.EditRepoOption
AllowOnlyContributorsToTrackTime: config.AllowOnlyContributorsToTrackTime,
EnableIssueDependencies: config.EnableDependencies,
}
- } else if unit, err := repo.GetUnit(unit_model.TypeExternalTracker); err == nil {
+ } else if unit, err := repo.GetUnit(db.DefaultContext, unit_model.TypeExternalTracker); err == nil {
config := unit.ExternalTrackerConfig()
hasIssues = true
externalTracker = &api.ExternalTracker{
@@ -47,9 +48,9 @@ func getRepoEditOptionFromRepo(repo *repo_model.Repository) *api.EditRepoOption
}
hasWiki := false
var externalWiki *api.ExternalWiki
- if _, err := repo.GetUnit(unit_model.TypeWiki); err == nil {
+ if _, err := repo.GetUnit(db.DefaultContext, unit_model.TypeWiki); err == nil {
hasWiki = true
- } else if unit, err := repo.GetUnit(unit_model.TypeExternalWiki); err == nil {
+ } else if unit, err := repo.GetUnit(db.DefaultContext, unit_model.TypeExternalWiki); err == nil {
hasWiki = true
config := unit.ExternalWikiConfig()
externalWiki = &api.ExternalWiki{
@@ -63,7 +64,7 @@ func getRepoEditOptionFromRepo(repo *repo_model.Repository) *api.EditRepoOption
allowRebase := false
allowRebaseMerge := false
allowSquash := false
- if unit, err := repo.GetUnit(unit_model.TypePullRequests); err == nil {
+ if unit, err := repo.GetUnit(db.DefaultContext, unit_model.TypePullRequests); err == nil {
config := unit.PullRequestsConfig()
hasPullRequests = true
ignoreWhitespaceConflicts = config.IgnoreWhitespaceConflicts
diff --git a/tests/integration/mirror_pull_test.go b/tests/integration/mirror_pull_test.go
index 753b7e7663..1bd91a48b5 100644
--- a/tests/integration/mirror_pull_test.go
+++ b/tests/integration/mirror_pull_test.go
@@ -7,6 +7,7 @@ import (
"context"
"testing"
+ "code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
@@ -57,7 +58,7 @@ func TestMirrorPull(t *testing.T) {
defer gitRepo.Close()
findOptions := repo_model.FindReleasesOptions{IncludeDrafts: true, IncludeTags: true}
- initCount, err := repo_model.GetReleaseCountByRepoID(mirror.ID, findOptions)
+ initCount, err := repo_model.GetReleaseCountByRepoID(db.DefaultContext, mirror.ID, findOptions)
assert.NoError(t, err)
assert.NoError(t, release_service.CreateRelease(gitRepo, &repo_model.Release{
@@ -80,7 +81,7 @@ func TestMirrorPull(t *testing.T) {
ok := mirror_service.SyncPullMirror(ctx, mirror.ID)
assert.True(t, ok)
- count, err := repo_model.GetReleaseCountByRepoID(mirror.ID, findOptions)
+ count, err := repo_model.GetReleaseCountByRepoID(db.DefaultContext, mirror.ID, findOptions)
assert.NoError(t, err)
assert.EqualValues(t, initCount+1, count)
@@ -91,7 +92,7 @@ func TestMirrorPull(t *testing.T) {
ok = mirror_service.SyncPullMirror(ctx, mirror.ID)
assert.True(t, ok)
- count, err = repo_model.GetReleaseCountByRepoID(mirror.ID, findOptions)
+ count, err = repo_model.GetReleaseCountByRepoID(db.DefaultContext, mirror.ID, findOptions)
assert.NoError(t, err)
assert.EqualValues(t, initCount, count)
}