1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-11 20:18:20 +00:00

Fix deletion of unprotected branches (#2630)

* fix deletion of unprotected branches

* fmt fix

* changed internal protected branch api

* fix lint error

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
This commit is contained in:
David Schneiderbauer
2017-10-02 22:23:41 +02:00
committed by Lauris BH
parent 3cc5b11b0d
commit e38e502e20
4 changed files with 12 additions and 12 deletions

View File

@@ -17,7 +17,7 @@ import (
"github.com/stretchr/testify/assert"
)
func assertProtectedBranch(t *testing.T, repoID int64, branchName string, isErr, canPush bool) {
func assertProtectedBranch(t *testing.T, repoID int64, branchName string, isErr, isProtected bool) {
reqURL := fmt.Sprintf("/api/internal/branch/%d/%s", repoID, url.QueryEscape(branchName))
req := NewRequest(t, "GET", reqURL)
t.Log(reqURL)
@@ -31,14 +31,14 @@ func assertProtectedBranch(t *testing.T, repoID int64, branchName string, isErr,
var branch models.ProtectedBranch
t.Log(string(resp.Body))
assert.NoError(t, json.Unmarshal(resp.Body, &branch))
assert.Equal(t, canPush, branch.CanPush)
assert.Equal(t, isProtected, branch.IsProtected())
}
}
func TestInternal_GetProtectedBranch(t *testing.T) {
prepareTestEnv(t)
assertProtectedBranch(t, 1, "master", false, true)
assertProtectedBranch(t, 1, "dev", false, true)
assertProtectedBranch(t, 1, "lunny/dev", false, true)
assertProtectedBranch(t, 1, "master", false, false)
assertProtectedBranch(t, 1, "dev", false, false)
assertProtectedBranch(t, 1, "lunny/dev", false, false)
}