1
1
mirror of https://github.com/go-gitea/gitea synced 2025-09-28 03:28:13 +00:00

Add webhook test for push event (#34442)

Confirm #9243 has been fixed.
This commit is contained in:
Lunny Xiao
2025-08-04 19:05:13 -07:00
committed by GitHub
parent de570b7dde
commit 920d62c0a7
2 changed files with 86 additions and 10 deletions

View File

@@ -56,7 +56,7 @@ func TestEditor(t *testing.T) {
func testEditorCreateFile(t *testing.T) {
session := loginUser(t, "user2")
testCreateFile(t, session, "user2", "repo1", "master", "test.txt", "Content")
testCreateFile(t, session, "user2", "repo1", "master", "", "test.txt", "Content")
testEditorActionPostRequestError(t, session, "/user2/repo1/_new/master/", map[string]string{
"tree_path": "test.txt",
"commit_choice": "direct",
@@ -69,11 +69,16 @@ func testEditorCreateFile(t *testing.T) {
}, `Branch "master" already exists in this repository.`)
}
func testCreateFile(t *testing.T, session *TestSession, user, repo, branch, filePath, content string) {
testEditorActionEdit(t, session, user, repo, "_new", branch, "", map[string]string{
"tree_path": filePath,
"content": content,
"commit_choice": "direct",
func testCreateFile(t *testing.T, session *TestSession, user, repo, baseBranchName, newBranchName, filePath, content string) {
commitChoice := "direct"
if newBranchName != "" && newBranchName != baseBranchName {
commitChoice = "commit-to-new-branch"
}
testEditorActionEdit(t, session, user, repo, "_new", baseBranchName, "", map[string]string{
"tree_path": filePath,
"content": content,
"commit_choice": commitChoice,
"new_branch_name": newBranchName,
})
}