aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJason Song <i@wolfogre.com>2023-01-09 11:50:54 +0800
committerGitHub <noreply@github.com>2023-01-09 11:50:54 +0800
commit7adc2de46404e32ed33f999d308ed56232cdfea5 (patch)
tree2404a22b5fa8a941eb5bfd16fd717fab29d899e4 /tests
parentb878155b8741c2769b6aa50a80609c36822451c9 (diff)
downloadgitea-7adc2de46404e32ed33f999d308ed56232cdfea5.tar.gz
gitea-7adc2de46404e32ed33f999d308ed56232cdfea5.zip
Use context parameter in models/git (#22367)
After #22362, we can feel free to use transactions without `db.DefaultContext`. And there are still lots of models using `db.DefaultContext`, I think we should refactor them carefully and one by one. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/api_repo_lfs_test.go16
-rw-r--r--tests/integration/lfs_getobject_test.go4
-rw-r--r--tests/integration/repo_tag_test.go4
3 files changed, 12 insertions, 12 deletions
diff --git a/tests/integration/api_repo_lfs_test.go b/tests/integration/api_repo_lfs_test.go
index 73599242db..c0ceaa8ba8 100644
--- a/tests/integration/api_repo_lfs_test.go
+++ b/tests/integration/api_repo_lfs_test.go
@@ -77,7 +77,7 @@ func TestAPILFSBatch(t *testing.T) {
content := []byte("dummy1")
oid := storeObjectInRepo(t, repo.ID, &content)
- defer git_model.RemoveLFSMetaObjectByOid(repo.ID, oid)
+ defer git_model.RemoveLFSMetaObjectByOid(db.DefaultContext, repo.ID, oid)
session := loginUser(t, "user2")
@@ -261,7 +261,7 @@ func TestAPILFSBatch(t *testing.T) {
content := []byte("dummy0")
storeObjectInRepo(t, repo2.ID, &content)
- meta, err := git_model.GetLFSMetaObjectByOid(repo.ID, p.Oid)
+ meta, err := git_model.GetLFSMetaObjectByOid(db.DefaultContext, repo.ID, p.Oid)
assert.Nil(t, meta)
assert.Equal(t, git_model.ErrLFSObjectNotExist, err)
@@ -276,7 +276,7 @@ func TestAPILFSBatch(t *testing.T) {
assert.Nil(t, br.Objects[0].Error)
assert.Empty(t, br.Objects[0].Actions)
- meta, err = git_model.GetLFSMetaObjectByOid(repo.ID, p.Oid)
+ meta, err = git_model.GetLFSMetaObjectByOid(db.DefaultContext, repo.ID, p.Oid)
assert.NoError(t, err)
assert.NotNil(t, meta)
@@ -337,7 +337,7 @@ func TestAPILFSUpload(t *testing.T) {
content := []byte("dummy3")
oid := storeObjectInRepo(t, repo.ID, &content)
- defer git_model.RemoveLFSMetaObjectByOid(repo.ID, oid)
+ defer git_model.RemoveLFSMetaObjectByOid(db.DefaultContext, repo.ID, oid)
session := loginUser(t, "user2")
@@ -366,7 +366,7 @@ func TestAPILFSUpload(t *testing.T) {
err = contentStore.Put(p, bytes.NewReader([]byte("dummy5")))
assert.NoError(t, err)
- meta, err := git_model.GetLFSMetaObjectByOid(repo.ID, p.Oid)
+ meta, err := git_model.GetLFSMetaObjectByOid(db.DefaultContext, repo.ID, p.Oid)
assert.Nil(t, meta)
assert.Equal(t, git_model.ErrLFSObjectNotExist, err)
@@ -379,7 +379,7 @@ func TestAPILFSUpload(t *testing.T) {
req := newRequest(t, p, "dummy5")
session.MakeRequest(t, req, http.StatusOK)
- meta, err = git_model.GetLFSMetaObjectByOid(repo.ID, p.Oid)
+ meta, err = git_model.GetLFSMetaObjectByOid(db.DefaultContext, repo.ID, p.Oid)
assert.NoError(t, err)
assert.NotNil(t, meta)
})
@@ -427,7 +427,7 @@ func TestAPILFSUpload(t *testing.T) {
assert.NoError(t, err)
assert.True(t, exist)
- meta, err := git_model.GetLFSMetaObjectByOid(repo.ID, p.Oid)
+ meta, err := git_model.GetLFSMetaObjectByOid(db.DefaultContext, repo.ID, p.Oid)
assert.NoError(t, err)
assert.NotNil(t, meta)
})
@@ -442,7 +442,7 @@ func TestAPILFSVerify(t *testing.T) {
content := []byte("dummy3")
oid := storeObjectInRepo(t, repo.ID, &content)
- defer git_model.RemoveLFSMetaObjectByOid(repo.ID, oid)
+ defer git_model.RemoveLFSMetaObjectByOid(db.DefaultContext, repo.ID, oid)
session := loginUser(t, "user2")
diff --git a/tests/integration/lfs_getobject_test.go b/tests/integration/lfs_getobject_test.go
index a191bcb61c..7b1b3e109c 100644
--- a/tests/integration/lfs_getobject_test.go
+++ b/tests/integration/lfs_getobject_test.go
@@ -28,7 +28,7 @@ func storeObjectInRepo(t *testing.T, repositoryID int64, content *[]byte) string
pointer, err := lfs.GeneratePointer(bytes.NewReader(*content))
assert.NoError(t, err)
- _, err = git_model.NewLFSMetaObject(&git_model.LFSMetaObject{Pointer: pointer, RepositoryID: repositoryID})
+ _, err = git_model.NewLFSMetaObject(db.DefaultContext, &git_model.LFSMetaObject{Pointer: pointer, RepositoryID: repositoryID})
assert.NoError(t, err)
contentStore := lfs.NewContentStore()
exist, err := contentStore.Exists(pointer)
@@ -44,7 +44,7 @@ func storeAndGetLfs(t *testing.T, content *[]byte, extraHeader *http.Header, exp
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)
+ defer git_model.RemoveLFSMetaObjectByOid(db.DefaultContext, repo.ID, oid)
session := loginUser(t, "user2")
diff --git a/tests/integration/repo_tag_test.go b/tests/integration/repo_tag_test.go
index 5ea9392a99..8667a6d6e9 100644
--- a/tests/integration/repo_tag_test.go
+++ b/tests/integration/repo_tag_test.go
@@ -32,12 +32,12 @@ func TestCreateNewTagProtected(t *testing.T) {
err := release.CreateNewTag(git.DefaultContext, owner, repo, "master", "v-1", "first tag")
assert.NoError(t, err)
- err = git_model.InsertProtectedTag(&git_model.ProtectedTag{
+ err = git_model.InsertProtectedTag(db.DefaultContext, &git_model.ProtectedTag{
RepoID: repo.ID,
NamePattern: "v-*",
})
assert.NoError(t, err)
- err = git_model.InsertProtectedTag(&git_model.ProtectedTag{
+ err = git_model.InsertProtectedTag(db.DefaultContext, &git_model.ProtectedTag{
RepoID: repo.ID,
NamePattern: "v-1.1",
AllowlistUserIDs: []int64{repo.OwnerID},