aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-12-03 10:48:26 +0800
committerGitHub <noreply@github.com>2022-12-03 10:48:26 +0800
commit0a7d3ff786508284224ada17956a65bb759d9265 (patch)
tree4860fca95c1432ab59c6723ee2b053b1c7d6779d /tests
parent8698458f48eafeab21014db544aa7160368856e1 (diff)
downloadgitea-0a7d3ff786508284224ada17956a65bb759d9265.tar.gz
gitea-0a7d3ff786508284224ada17956a65bb759d9265.zip
refactor some functions to support ctx as first parameter (#21878)
Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/api_issue_tracked_time_test.go2
-rw-r--r--tests/integration/api_repo_lfs_test.go3
-rw-r--r--tests/integration/git_test.go4
-rw-r--r--tests/integration/lfs_getobject_test.go3
-rw-r--r--tests/integration/repo_search_test.go5
5 files changed, 10 insertions, 7 deletions
diff --git a/tests/integration/api_issue_tracked_time_test.go b/tests/integration/api_issue_tracked_time_test.go
index 3080b5e194..eda4150f8c 100644
--- a/tests/integration/api_issue_tracked_time_test.go
+++ b/tests/integration/api_issue_tracked_time_test.go
@@ -43,7 +43,7 @@ func TestAPIGetTrackedTimes(t *testing.T) {
assert.EqualValues(t, issue2.ID, apiTimes[i].IssueID)
assert.Equal(t, time.Created.Unix(), apiTimes[i].Created.Unix())
assert.Equal(t, time.Time, apiTimes[i].Time)
- user, err := user_model.GetUserByID(time.UserID)
+ user, err := user_model.GetUserByID(db.DefaultContext, time.UserID)
assert.NoError(t, err)
assert.Equal(t, user.Name, apiTimes[i].UserName)
}
diff --git a/tests/integration/api_repo_lfs_test.go b/tests/integration/api_repo_lfs_test.go
index d4334ff8b9..73599242db 100644
--- a/tests/integration/api_repo_lfs_test.go
+++ b/tests/integration/api_repo_lfs_test.go
@@ -11,6 +11,7 @@ import (
"strings"
"testing"
+ "code.gitea.io/gitea/models/db"
git_model "code.gitea.io/gitea/models/git"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
@@ -61,7 +62,7 @@ func createLFSTestRepository(t *testing.T, name string) *repo_model.Repository {
ctx := NewAPITestContext(t, "user2", "lfs-"+name+"-repo")
t.Run("CreateRepo", doAPICreateRepository(ctx, false))
- repo, err := repo_model.GetRepositoryByOwnerAndName("user2", "lfs-"+name+"-repo")
+ repo, err := repo_model.GetRepositoryByOwnerAndName(db.DefaultContext, "user2", "lfs-"+name+"-repo")
assert.NoError(t, err)
return repo
diff --git a/tests/integration/git_test.go b/tests/integration/git_test.go
index 6508df1ef0..8d29a161d5 100644
--- a/tests/integration/git_test.go
+++ b/tests/integration/git_test.go
@@ -570,7 +570,7 @@ func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) {
t.Run("SuccessfullyPushAndCreateTestRepository", doGitPushTestRepository(tmpDir, "origin", "master"))
// Finally, fetch repo from database and ensure the correct repository has been created
- repo, err := repo_model.GetRepositoryByOwnerAndName(ctx.Username, ctx.Reponame)
+ repo, err := repo_model.GetRepositoryByOwnerAndName(db.DefaultContext, ctx.Username, ctx.Reponame)
assert.NoError(t, err)
assert.False(t, repo.IsEmpty)
assert.True(t, repo.IsPrivate)
@@ -698,7 +698,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB
pr1, pr2 *issues_model.PullRequest
commit string
)
- repo, err := repo_model.GetRepositoryByOwnerAndName(ctx.Username, ctx.Reponame)
+ repo, err := repo_model.GetRepositoryByOwnerAndName(db.DefaultContext, ctx.Username, ctx.Reponame)
if !assert.NoError(t, err) {
return
}
diff --git a/tests/integration/lfs_getobject_test.go b/tests/integration/lfs_getobject_test.go
index 1a486b6051..a191bcb61c 100644
--- a/tests/integration/lfs_getobject_test.go
+++ b/tests/integration/lfs_getobject_test.go
@@ -11,6 +11,7 @@ import (
"net/http/httptest"
"testing"
+ "code.gitea.io/gitea/models/db"
git_model "code.gitea.io/gitea/models/git"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/json"
@@ -40,7 +41,7 @@ func storeObjectInRepo(t *testing.T, repositoryID int64, content *[]byte) string
}
func storeAndGetLfs(t *testing.T, content *[]byte, extraHeader *http.Header, expectedStatus int) *httptest.ResponseRecorder {
- repo, err := repo_model.GetRepositoryByOwnerAndName("user2", "repo1")
+ repo, err := repo_model.GetRepositoryByOwnerAndName(db.DefaultContext, "user2", "repo1")
assert.NoError(t, err)
oid := storeObjectInRepo(t, repo.ID, content)
defer git_model.RemoveLFSMetaObjectByOid(repo.ID, oid)
diff --git a/tests/integration/repo_search_test.go b/tests/integration/repo_search_test.go
index 34328100fd..d113d1e57d 100644
--- a/tests/integration/repo_search_test.go
+++ b/tests/integration/repo_search_test.go
@@ -7,6 +7,7 @@ import (
"net/http"
"testing"
+ "code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
code_indexer "code.gitea.io/gitea/modules/indexer/code"
"code.gitea.io/gitea/modules/setting"
@@ -28,7 +29,7 @@ func resultFilenames(t testing.TB, doc *HTMLDoc) []string {
func TestSearchRepo(t *testing.T) {
defer tests.PrepareTestEnv(t)()
- repo, err := repo_model.GetRepositoryByOwnerAndName("user2", "repo1")
+ repo, err := repo_model.GetRepositoryByOwnerAndName(db.DefaultContext, "user2", "repo1")
assert.NoError(t, err)
executeIndexer(t, repo, code_indexer.UpdateRepoIndexer)
@@ -38,7 +39,7 @@ func TestSearchRepo(t *testing.T) {
setting.Indexer.IncludePatterns = setting.IndexerGlobFromString("**.txt")
setting.Indexer.ExcludePatterns = setting.IndexerGlobFromString("**/y/**")
- repo, err = repo_model.GetRepositoryByOwnerAndName("user2", "glob")
+ repo, err = repo_model.GetRepositoryByOwnerAndName(db.DefaultContext, "user2", "glob")
assert.NoError(t, err)
executeIndexer(t, repo, code_indexer.UpdateRepoIndexer)