aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/repofiles_delete_test.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-01-19 23:26:57 +0000
committerGitHub <noreply@github.com>2022-01-19 23:26:57 +0000
commit5cb0c9aa0d7eed087055b1efca79628957207d36 (patch)
treed117a514e1f17e5f6bfcda1be273f6a971112663 /integrations/repofiles_delete_test.go
parent4563148a61ba892e8f2bb66342f00a950bcd5315 (diff)
downloadgitea-5cb0c9aa0d7eed087055b1efca79628957207d36.tar.gz
gitea-5cb0c9aa0d7eed087055b1efca79628957207d36.zip
Propagate context and ensure git commands run in request context (#17868)
This PR continues the work in #17125 by progressively ensuring that git commands run within the request context. This now means that the if there is a git repo already open in the context it will be used instead of reopening it. Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'integrations/repofiles_delete_test.go')
-rw-r--r--integrations/repofiles_delete_test.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/integrations/repofiles_delete_test.go b/integrations/repofiles_delete_test.go
index d2bfe31d95..09794f8c9f 100644
--- a/integrations/repofiles_delete_test.go
+++ b/integrations/repofiles_delete_test.go
@@ -10,6 +10,7 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
+ "code.gitea.io/gitea/modules/git"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/test"
files_service "code.gitea.io/gitea/services/repository/files"
@@ -80,7 +81,7 @@ func testDeleteRepoFile(t *testing.T, u *url.URL) {
opts := getDeleteRepoFileOptions(repo)
t.Run("Delete README.md file", func(t *testing.T) {
- fileResponse, err := files_service.DeleteRepoFile(repo, doer, opts)
+ fileResponse, err := files_service.DeleteRepoFile(git.DefaultContext, repo, doer, opts)
assert.NoError(t, err)
expectedFileResponse := getExpectedDeleteFileResponse(u)
assert.NotNil(t, fileResponse)
@@ -92,7 +93,7 @@ func testDeleteRepoFile(t *testing.T, u *url.URL) {
})
t.Run("Verify README.md has been deleted", func(t *testing.T) {
- fileResponse, err := files_service.DeleteRepoFile(repo, doer, opts)
+ fileResponse, err := files_service.DeleteRepoFile(git.DefaultContext, repo, doer, opts)
assert.Nil(t, fileResponse)
expectedError := "repository file does not exist [path: " + opts.TreePath + "]"
assert.EqualError(t, err, expectedError)
@@ -122,7 +123,7 @@ func testDeleteRepoFileWithoutBranchNames(t *testing.T, u *url.URL) {
opts.NewBranch = ""
t.Run("Delete README.md without Branch Name", func(t *testing.T) {
- fileResponse, err := files_service.DeleteRepoFile(repo, doer, opts)
+ fileResponse, err := files_service.DeleteRepoFile(git.DefaultContext, repo, doer, opts)
assert.NoError(t, err)
expectedFileResponse := getExpectedDeleteFileResponse(u)
assert.NotNil(t, fileResponse)
@@ -151,7 +152,7 @@ func TestDeleteRepoFileErrors(t *testing.T) {
t.Run("Bad branch", func(t *testing.T) {
opts := getDeleteRepoFileOptions(repo)
opts.OldBranch = "bad_branch"
- fileResponse, err := files_service.DeleteRepoFile(repo, doer, opts)
+ fileResponse, err := files_service.DeleteRepoFile(git.DefaultContext, repo, doer, opts)
assert.Error(t, err)
assert.Nil(t, fileResponse)
expectedError := "branch does not exist [name: " + opts.OldBranch + "]"
@@ -162,7 +163,7 @@ func TestDeleteRepoFileErrors(t *testing.T) {
opts := getDeleteRepoFileOptions(repo)
origSHA := opts.SHA
opts.SHA = "bad_sha"
- fileResponse, err := files_service.DeleteRepoFile(repo, doer, opts)
+ fileResponse, err := files_service.DeleteRepoFile(git.DefaultContext, repo, doer, opts)
assert.Nil(t, fileResponse)
assert.Error(t, err)
expectedError := "sha does not match [given: " + opts.SHA + ", expected: " + origSHA + "]"
@@ -172,7 +173,7 @@ func TestDeleteRepoFileErrors(t *testing.T) {
t.Run("New branch already exists", func(t *testing.T) {
opts := getDeleteRepoFileOptions(repo)
opts.NewBranch = "develop"
- fileResponse, err := files_service.DeleteRepoFile(repo, doer, opts)
+ fileResponse, err := files_service.DeleteRepoFile(git.DefaultContext, repo, doer, opts)
assert.Nil(t, fileResponse)
assert.Error(t, err)
expectedError := "branch already exists [name: " + opts.NewBranch + "]"
@@ -182,7 +183,7 @@ func TestDeleteRepoFileErrors(t *testing.T) {
t.Run("TreePath is empty:", func(t *testing.T) {
opts := getDeleteRepoFileOptions(repo)
opts.TreePath = ""
- fileResponse, err := files_service.DeleteRepoFile(repo, doer, opts)
+ fileResponse, err := files_service.DeleteRepoFile(git.DefaultContext, repo, doer, opts)
assert.Nil(t, fileResponse)
assert.Error(t, err)
expectedError := "path contains a malformed path component [path: ]"
@@ -192,7 +193,7 @@ func TestDeleteRepoFileErrors(t *testing.T) {
t.Run("TreePath is a git directory:", func(t *testing.T) {
opts := getDeleteRepoFileOptions(repo)
opts.TreePath = ".git"
- fileResponse, err := files_service.DeleteRepoFile(repo, doer, opts)
+ fileResponse, err := files_service.DeleteRepoFile(git.DefaultContext, repo, doer, opts)
assert.Nil(t, fileResponse)
assert.Error(t, err)
expectedError := "path contains a malformed path component [path: " + opts.TreePath + "]"