Skip to content

Commit 1a3872b

Browse files
committed
more test coverage
1 parent 9606f7e commit 1a3872b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/integration/api_branch_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func testAPIGetBranchProtection(t *testing.T, branchName string, expectedHTTPSta
4949
return nil
5050
}
5151

52-
func testAPICreateBranchProtection(t *testing.T, branchName string, expectedHTTPStatus int) {
52+
func testAPICreateBranchProtection(t *testing.T, branchName string, expectedPriority, expectedHTTPStatus int) {
5353
token := getUserToken(t, "user2", auth_model.AccessTokenScopeWriteRepository)
5454
req := NewRequestWithJSON(t, "POST", "/api/v1/repos/user2/repo1/branch_protections", &api.BranchProtection{
5555
RuleName: branchName,
@@ -60,6 +60,7 @@ func testAPICreateBranchProtection(t *testing.T, branchName string, expectedHTTP
6060
var branchProtection api.BranchProtection
6161
DecodeJSON(t, resp, &branchProtection)
6262
assert.EqualValues(t, branchName, branchProtection.RuleName)
63+
assert.EqualValues(t, expectedPriority, branchProtection.Priority)
6364
}
6465
}
6566

@@ -189,13 +190,13 @@ func TestAPIBranchProtection(t *testing.T) {
189190
defer tests.PrepareTestEnv(t)()
190191

191192
// Branch protection on branch that not exist
192-
testAPICreateBranchProtection(t, "master/doesnotexist", http.StatusCreated)
193+
testAPICreateBranchProtection(t, "master/doesnotexist", 1, http.StatusCreated)
193194
// Get branch protection on branch that exist but not branch protection
194195
testAPIGetBranchProtection(t, "master", http.StatusNotFound)
195196

196-
testAPICreateBranchProtection(t, "master", http.StatusCreated)
197+
testAPICreateBranchProtection(t, "master", 2, http.StatusCreated)
197198
// Can only create once
198-
testAPICreateBranchProtection(t, "master", http.StatusForbidden)
199+
testAPICreateBranchProtection(t, "master", 0, http.StatusForbidden)
199200

200201
// Can't delete a protected branch
201202
testAPIDeleteBranch(t, "master", http.StatusForbidden)

0 commit comments

Comments
 (0)