Fix various bugs (#37096)

* Fix #36001
* Fix #35498
* Fix #35395
* Fix #35160
* Fix #35058
* Fix #35445
This commit is contained in:
wxiaoguang
2026-04-04 04:03:59 +08:00
committed by GitHub
parent f9f9876f2c
commit 2c2d7e6f64
18 changed files with 113 additions and 78 deletions
+8 -3
View File
@@ -362,15 +362,20 @@ func testAPIRenameBranch(t *testing.T, doerName, ownerName, repoName, from, to s
func TestAPIBranchProtection(t *testing.T) {
defer tests.PrepareTestEnv(t)()
// Branch protection on branch that not exist
testAPICreateBranchProtection(t, "master/doesnotexist", 1, http.StatusCreated)
// Can create branch protection on branch that not exist
testAPICreateBranchProtection(t, "non-existing/branch", 1, http.StatusCreated)
testAPIGetBranchProtection(t, "non-existing/branch", http.StatusOK)
testAPIDeleteBranchProtection(t, "non-existing/branch", http.StatusNoContent)
// Get branch protection on branch that exist but not branch protection
testAPIGetBranchProtection(t, "master", http.StatusNotFound)
testAPICreateBranchProtection(t, "master", 2, http.StatusCreated)
testAPICreateBranchProtection(t, "master", 1, http.StatusCreated)
// Can only create once
testAPICreateBranchProtection(t, "master", 0, http.StatusForbidden)
testAPICreateBranchProtection(t, "other-branch", 2, http.StatusCreated)
// Can't delete a protected branch
testAPIDeleteBranch(t, "master", http.StatusForbidden)