mirror of https://github.com/go-gitea/gitea.git
refactor tests
This commit is contained in:
parent
8313490acb
commit
c7395dc05a
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"maps"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
|
@ -19,178 +20,102 @@ import (
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/json"
|
|
||||||
"code.gitea.io/gitea/modules/test"
|
"code.gitea.io/gitea/modules/test"
|
||||||
"code.gitea.io/gitea/modules/translation"
|
"code.gitea.io/gitea/modules/translation"
|
||||||
|
"code.gitea.io/gitea/modules/util"
|
||||||
"code.gitea.io/gitea/tests"
|
"code.gitea.io/gitea/tests"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateFile(t *testing.T) {
|
func TestEditor(t *testing.T) {
|
||||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||||
session := loginUser(t, "user2")
|
sessionUser2 := loginUser(t, "user2")
|
||||||
testCreateFile(t, session, "user2", "repo1", "master", "test.txt", "Content")
|
t.Run("CreateFile", func(t *testing.T) {
|
||||||
|
testCreateFile(t, sessionUser2, "user2", "repo1", "master", "test.txt", "Content")
|
||||||
|
})
|
||||||
|
t.Run("EditFile", func(t *testing.T) {
|
||||||
|
testEditFile(t, sessionUser2, "user2", "repo1", "master", "README.md", "Hello, World (direct)\n")
|
||||||
|
})
|
||||||
|
t.Run("EditFileToNewBranch", func(t *testing.T) {
|
||||||
|
testEditFileToNewBranch(t, sessionUser2, "user2", "repo1", "master", "feature/test", "README.md", "Hello, World (commit-to-new-branch)\n")
|
||||||
|
})
|
||||||
|
t.Run("ForkToEditFile", func(t *testing.T) {
|
||||||
|
testForkToEditFile(t, loginUser(t, "user4"), "user4", "user2", "repo1", "master", "README.md")
|
||||||
|
})
|
||||||
|
t.Run("WebGitCommitEmail", testWebGitCommitEmail)
|
||||||
|
t.Run("CreateFileOnProtectedBranch", testCreateFileOnProtectedBranch)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCreateFile(t *testing.T, session *TestSession, user, repo, branch, filePath, content string) {
|
func testCreateFile(t *testing.T, session *TestSession, user, repo, branch, filePath, content string) {
|
||||||
// Request editor page
|
testEditorActionEdit(t, session, user, repo, "_new", branch, "", map[string]string{
|
||||||
newURL := fmt.Sprintf("/%s/%s/_new/%s/", user, repo, branch)
|
|
||||||
req := NewRequest(t, "GET", newURL)
|
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
|
||||||
|
|
||||||
doc := NewHTMLParser(t, resp.Body)
|
|
||||||
lastCommit := doc.GetInputValueByName("last_commit")
|
|
||||||
assert.NotEmpty(t, lastCommit)
|
|
||||||
|
|
||||||
// Save new file to master branch
|
|
||||||
req = NewRequestWithValues(t, "POST", newURL, map[string]string{
|
|
||||||
"_csrf": doc.GetCSRF(),
|
|
||||||
"last_commit": lastCommit,
|
|
||||||
"tree_path": filePath,
|
"tree_path": filePath,
|
||||||
"content": content,
|
"content": content,
|
||||||
"commit_choice": "direct",
|
"commit_choice": "direct",
|
||||||
})
|
})
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
|
||||||
assert.NotEmpty(t, test.RedirectURL(resp))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateFileOnProtectedBranch(t *testing.T) {
|
func testCreateFileOnProtectedBranch(t *testing.T) {
|
||||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
|
||||||
session := loginUser(t, "user2")
|
session := loginUser(t, "user2")
|
||||||
|
// Change the "master" branch to "protected"
|
||||||
csrf := GetUserCSRFToken(t, session)
|
|
||||||
// Change master branch to protected
|
|
||||||
req := NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches/edit", map[string]string{
|
req := NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches/edit", map[string]string{
|
||||||
"_csrf": csrf,
|
"_csrf": GetUserCSRFToken(t, session),
|
||||||
"rule_name": "master",
|
"rule_name": "master",
|
||||||
"enable_push": "true",
|
"enable_push": "true",
|
||||||
})
|
})
|
||||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||||
// Check if master branch has been locked successfully
|
|
||||||
flashMsg := session.GetCookieFlashMessage()
|
flashMsg := session.GetCookieFlashMessage()
|
||||||
assert.Equal(t, `Branch protection for rule "master" has been updated.`, flashMsg.SuccessMsg)
|
assert.Equal(t, `Branch protection for rule "master" has been updated.`, flashMsg.SuccessMsg)
|
||||||
|
|
||||||
// Request editor page
|
// Try to commit a file to the "master" branch and it should fail
|
||||||
req = NewRequest(t, "GET", "/user2/repo1/_new/master/")
|
resp := testEditorActionPostRequest(t, session, "/user2/repo1/_new/master/", map[string]string{"tree_path": "test-protected-branch.txt", "commit_choice": "direct"})
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
assert.Equal(t, http.StatusBadRequest, resp.Code)
|
||||||
|
assert.Equal(t, `Cannot commit to protected branch "master".`, test.ParseJSONError(resp.Body.Bytes()).ErrorMessage)
|
||||||
doc := NewHTMLParser(t, resp.Body)
|
|
||||||
lastCommit := doc.GetInputValueByName("last_commit")
|
|
||||||
assert.NotEmpty(t, lastCommit)
|
|
||||||
|
|
||||||
// Save new file to master branch
|
|
||||||
req = NewRequestWithValues(t, "POST", "/user2/repo1/_new/master/", map[string]string{
|
|
||||||
"_csrf": doc.GetCSRF(),
|
|
||||||
"last_commit": lastCommit,
|
|
||||||
"tree_path": "test.txt",
|
|
||||||
"content": "Content",
|
|
||||||
"commit_choice": "direct",
|
|
||||||
})
|
|
||||||
|
|
||||||
resp = session.MakeRequest(t, req, http.StatusBadRequest)
|
|
||||||
respErr := test.ParseJSONError(resp.Body.Bytes())
|
|
||||||
assert.Equal(t, `Cannot commit to protected branch "master".`, respErr.ErrorMessage)
|
|
||||||
|
|
||||||
// remove the protected branch
|
|
||||||
csrf = GetUserCSRFToken(t, session)
|
|
||||||
|
|
||||||
// Change master branch to protected
|
|
||||||
req = NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches/1/delete", map[string]string{
|
|
||||||
"_csrf": csrf,
|
|
||||||
})
|
|
||||||
|
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
|
||||||
|
|
||||||
res := make(map[string]string)
|
|
||||||
assert.NoError(t, json.NewDecoder(resp.Body).Decode(&res))
|
|
||||||
assert.Equal(t, "/user2/repo1/settings/branches", res["redirect"])
|
|
||||||
|
|
||||||
// Check if master branch has been locked successfully
|
|
||||||
flashMsg = session.GetCookieFlashMessage()
|
|
||||||
assert.Equal(t, `Removing branch protection rule "1" failed.`, flashMsg.ErrorMsg)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePath, newContent string) *httptest.ResponseRecorder {
|
func testEditorActionPostRequest(t *testing.T, session *TestSession, requestPath string, params map[string]string) *httptest.ResponseRecorder {
|
||||||
// Get to the 'edit this file' page
|
req := NewRequest(t, "GET", requestPath)
|
||||||
req := NewRequest(t, "GET", path.Join(user, repo, "_edit", branch, filePath))
|
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
lastCommit := htmlDoc.GetInputValueByName("last_commit")
|
form := map[string]string{
|
||||||
assert.NotEmpty(t, lastCommit)
|
|
||||||
|
|
||||||
// Submit the edits
|
|
||||||
req = NewRequestWithValues(t, "POST", path.Join(user, repo, "_edit", branch, filePath),
|
|
||||||
map[string]string{
|
|
||||||
"_csrf": htmlDoc.GetCSRF(),
|
"_csrf": htmlDoc.GetCSRF(),
|
||||||
"last_commit": lastCommit,
|
"last_commit": htmlDoc.GetInputValueByName("last_commit"),
|
||||||
"tree_path": filePath,
|
}
|
||||||
"content": newContent,
|
maps.Copy(form, params)
|
||||||
"commit_choice": "direct",
|
req = NewRequestWithValues(t, "POST", requestPath, form)
|
||||||
},
|
return session.MakeRequest(t, req, NoExpectedStatus)
|
||||||
)
|
}
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
|
||||||
|
func testEditorActionEdit(t *testing.T, session *TestSession, user, repo, editorAction, branch, filePath string, params map[string]string) *httptest.ResponseRecorder {
|
||||||
|
params["tree_path"] = util.IfZero(params["tree_path"], filePath)
|
||||||
|
newBranchName := util.Iif(params["commit_choice"] == "direct", branch, params["new_branch_name"])
|
||||||
|
resp := testEditorActionPostRequest(t, session, fmt.Sprintf("/%s/%s/%s/%s/%s", user, repo, editorAction, branch, filePath), params)
|
||||||
|
assert.Equal(t, http.StatusOK, resp.Code)
|
||||||
assert.NotEmpty(t, test.RedirectURL(resp))
|
assert.NotEmpty(t, test.RedirectURL(resp))
|
||||||
|
req := NewRequest(t, "GET", path.Join(user, repo, "raw/branch", newBranchName, params["tree_path"]))
|
||||||
// Verify the change
|
|
||||||
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", branch, filePath))
|
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
assert.Equal(t, newContent, resp.Body.String())
|
assert.Equal(t, params["content"], resp.Body.String())
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, branch, targetBranch, filePath, newContent string) *httptest.ResponseRecorder {
|
func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePath, newContent string) {
|
||||||
// Get to the 'edit this file' page
|
testEditorActionEdit(t, session, user, repo, "_edit", branch, filePath, map[string]string{
|
||||||
req := NewRequest(t, "GET", path.Join(user, repo, "_edit", branch, filePath))
|
"content": newContent,
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
"commit_choice": "direct",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, branch, targetBranch, filePath, newContent string) {
|
||||||
lastCommit := htmlDoc.GetInputValueByName("last_commit")
|
testEditorActionEdit(t, session, user, repo, "_edit", branch, filePath, map[string]string{
|
||||||
assert.NotEmpty(t, lastCommit)
|
|
||||||
|
|
||||||
// Submit the edits
|
|
||||||
req = NewRequestWithValues(t, "POST", path.Join(user, repo, "_edit", branch, filePath),
|
|
||||||
map[string]string{
|
|
||||||
"_csrf": htmlDoc.GetCSRF(),
|
|
||||||
"last_commit": lastCommit,
|
|
||||||
"tree_path": filePath,
|
|
||||||
"content": newContent,
|
"content": newContent,
|
||||||
"commit_choice": "commit-to-new-branch",
|
"commit_choice": "commit-to-new-branch",
|
||||||
"new_branch_name": targetBranch,
|
"new_branch_name": targetBranch,
|
||||||
},
|
|
||||||
)
|
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
|
||||||
assert.NotEmpty(t, test.RedirectURL(resp))
|
|
||||||
|
|
||||||
// Verify the change
|
|
||||||
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", targetBranch, filePath))
|
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
|
||||||
assert.Equal(t, newContent, resp.Body.String())
|
|
||||||
|
|
||||||
return resp
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestEditFile(t *testing.T) {
|
|
||||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
|
||||||
session := loginUser(t, "user2")
|
|
||||||
testEditFile(t, session, "user2", "repo1", "master", "README.md", "Hello, World (Edited)\n")
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEditFileToNewBranch(t *testing.T) {
|
func testWebGitCommitEmail(t *testing.T) {
|
||||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
|
||||||
session := loginUser(t, "user2")
|
|
||||||
testEditFileToNewBranch(t, session, "user2", "repo1", "master", "feature/test", "README.md", "Hello, World (Edited)\n")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWebGitCommitEmail(t *testing.T) {
|
|
||||||
onGiteaRun(t, func(t *testing.T, _ *url.URL) {
|
|
||||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||||
require.True(t, user.KeepEmailPrivate)
|
require.True(t, user.KeepEmailPrivate)
|
||||||
|
|
||||||
|
|
@ -338,10 +263,10 @@ index 0000000000..bbbbbbbbbb
|
||||||
// By the way, test the "cherrypick" page: a successful revert redirects to the main branch
|
// By the way, test the "cherrypick" page: a successful revert redirects to the main branch
|
||||||
assert.Equal(t, "/user2/repo1/src/branch/master", test.RedirectURL(resp1))
|
assert.Equal(t, "/user2/repo1/src/branch/master", test.RedirectURL(resp1))
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func forkToEdit(t *testing.T, session *TestSession, owner, repo, operation, branch, filePath string) {
|
func testForkToEditFile(t *testing.T, session *TestSession, user, owner, repo, branch, filePath string) {
|
||||||
|
forkToEdit := func(t *testing.T, session *TestSession, owner, repo, operation, branch, filePath string) {
|
||||||
// visit the base repo, see the "Add File" button
|
// visit the base repo, see the "Add File" button
|
||||||
req := NewRequest(t, "GET", path.Join(owner, repo))
|
req := NewRequest(t, "GET", path.Join(owner, repo))
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
@ -359,7 +284,7 @@ func forkToEdit(t *testing.T, session *TestSession, owner, repo, operation, bran
|
||||||
assert.JSONEq(t, `{"redirect":""}`, resp.Body.String())
|
assert.JSONEq(t, `{"redirect":""}`, resp.Body.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func testForkToEditFile(t *testing.T, session *TestSession, user, owner, repo, branch, filePath string) {
|
t.Run("ForkButArchived", func(t *testing.T) {
|
||||||
// Fork repository because we can't edit it
|
// Fork repository because we can't edit it
|
||||||
forkToEdit(t, session, owner, repo, "_edit", branch, filePath)
|
forkToEdit(t, session, owner, repo, "_edit", branch, filePath)
|
||||||
|
|
||||||
|
|
@ -387,46 +312,51 @@ func testForkToEditFile(t *testing.T, session *TestSession, user, owner, repo, b
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||||
|
})
|
||||||
|
|
||||||
// Fork repository again
|
// Fork repository again, and check the existence of the forked repo with unique name
|
||||||
forkToEdit(t, session, owner, repo, "_edit", branch, filePath)
|
forkToEdit(t, session, owner, repo, "_edit", branch, filePath)
|
||||||
|
session.MakeRequest(t, NewRequestf(t, "GET", "/%s/%s-1", user, repo), http.StatusOK)
|
||||||
|
|
||||||
// Check the existence of the forked repo with unique name
|
t.Run("CheckBaseRepoForm", func(t *testing.T) {
|
||||||
req = NewRequestf(t, "GET", "/%s/%s-1", user, repo)
|
|
||||||
session.MakeRequest(t, req, http.StatusOK)
|
|
||||||
|
|
||||||
// the base repo's edit form should have the correct action and upload links (pointing to the forked repo)
|
// the base repo's edit form should have the correct action and upload links (pointing to the forked repo)
|
||||||
req = NewRequest(t, "GET", path.Join(owner, repo, "_upload", branch, filePath))
|
req := NewRequest(t, "GET", path.Join(owner, repo, "_upload", branch, filePath))
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
|
|
||||||
form := htmlDoc.doc.Find(".form-fetch-action")
|
uploadForm := htmlDoc.doc.Find(".form-fetch-action")
|
||||||
formAction := form.AttrOr("action", "")
|
formAction := uploadForm.AttrOr("action", "")
|
||||||
assert.Equal(t, fmt.Sprintf("/%s/%s-1/_upload/%s/%s?from_base_branch=%s", user, repo, branch, filePath, branch), formAction)
|
assert.Equal(t, fmt.Sprintf("/%s/%s-1/_upload/%s/%s?from_base_branch=%s", user, repo, branch, filePath, branch), formAction)
|
||||||
uploadLink := form.Find(".dropzone").AttrOr("data-link-url", "")
|
uploadLink := uploadForm.Find(".dropzone").AttrOr("data-link-url", "")
|
||||||
assert.Equal(t, fmt.Sprintf("/%s/%s-1/upload-file", user, repo), uploadLink)
|
assert.Equal(t, fmt.Sprintf("/%s/%s-1/upload-file", user, repo), uploadLink)
|
||||||
newBranchName := form.Find("input[name=new_branch_name]").AttrOr("value", "")
|
newBranchName := uploadForm.Find("input[name=new_branch_name]").AttrOr("value", "")
|
||||||
assert.Equal(t, user+"-patch-1", newBranchName)
|
assert.Equal(t, user+"-patch-1", newBranchName)
|
||||||
commitChoice := form.Find("input[name=commit_choice][checked]").AttrOr("value", "")
|
commitChoice := uploadForm.Find("input[name=commit_choice][checked]").AttrOr("value", "")
|
||||||
assert.Equal(t, "commit-to-new-branch", commitChoice)
|
assert.Equal(t, "commit-to-new-branch", commitChoice)
|
||||||
lastCommit := form.Find("input[name=last_commit]").AttrOr("value", "")
|
lastCommit := uploadForm.Find("input[name=last_commit]").AttrOr("value", "")
|
||||||
assert.NotEmpty(t, lastCommit)
|
assert.NotEmpty(t, lastCommit)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("ViewBaseEditFormAndCommitToFork", func(t *testing.T) {
|
||||||
|
req := NewRequest(t, "GET", path.Join(owner, repo, "_edit", branch, filePath))
|
||||||
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
editRequestForm := map[string]string{
|
editRequestForm := map[string]string{
|
||||||
"_csrf": GetUserCSRFToken(t, session),
|
"_csrf": GetUserCSRFToken(t, session),
|
||||||
"last_commit": lastCommit,
|
"last_commit": htmlDoc.GetInputValueByName("last_commit"),
|
||||||
"tree_path": filePath,
|
"tree_path": filePath,
|
||||||
"content": "new content in fork",
|
"content": "new content in fork",
|
||||||
"commit_choice": commitChoice,
|
"commit_choice": "commit-to-new-branch",
|
||||||
"new_branch_name": "master",
|
|
||||||
}
|
}
|
||||||
// change a file in the forked repo with existing branch name (should fail)
|
// change a file in the forked repo with existing branch name (should fail)
|
||||||
|
editRequestForm["new_branch_name"] = "master"
|
||||||
req = NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s-1/_edit/%s/%s?from_base_branch=%s", user, repo, branch, filePath, branch), editRequestForm)
|
req = NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s-1/_edit/%s/%s?from_base_branch=%s", user, repo, branch, filePath, branch), editRequestForm)
|
||||||
resp = session.MakeRequest(t, req, http.StatusBadRequest)
|
resp = session.MakeRequest(t, req, http.StatusBadRequest)
|
||||||
respJSON := test.ParseJSONError(resp.Body.Bytes())
|
respJSON := test.ParseJSONError(resp.Body.Bytes())
|
||||||
assert.Equal(t, `Branch "master" already exists in your fork, please choose a new branch name.`, respJSON.ErrorMessage)
|
assert.Equal(t, `Branch "master" already exists in your fork, please choose a new branch name.`, respJSON.ErrorMessage)
|
||||||
|
|
||||||
// change a file in the forked repo (should succeed)
|
// change a file in the forked repo (should succeed)
|
||||||
|
newBranchName := htmlDoc.GetInputValueByName("new_branch_name")
|
||||||
editRequestForm["new_branch_name"] = newBranchName
|
editRequestForm["new_branch_name"] = newBranchName
|
||||||
req = NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s-1/_edit/%s/%s?from_base_branch=%s", user, repo, branch, filePath, branch), editRequestForm)
|
req = NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s-1/_edit/%s/%s?from_base_branch=%s", user, repo, branch, filePath, branch), editRequestForm)
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
@ -436,11 +366,5 @@ func testForkToEditFile(t *testing.T, session *TestSession, user, owner, repo, b
|
||||||
req = NewRequest(t, "GET", fmt.Sprintf("/%s/%s-1/src/branch/%s/%s", user, repo, newBranchName, filePath))
|
req = NewRequest(t, "GET", fmt.Sprintf("/%s/%s-1/src/branch/%s/%s", user, repo, newBranchName, filePath))
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
assert.Contains(t, resp.Body.String(), "new content in fork")
|
assert.Contains(t, resp.Body.String(), "new content in fork")
|
||||||
}
|
|
||||||
|
|
||||||
func TestForkToEditFile(t *testing.T) {
|
|
||||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
|
||||||
session := loginUser(t, "user4")
|
|
||||||
testForkToEditFile(t, session, "user4", "user2", "repo1", "master", "README.md")
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue