-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix API for branches with slashes (#2096)
- Loading branch information
1 parent
fea902a
commit f99489d
Showing
4 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2017 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package integrations | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
api "code.gitea.io/sdk/gitea" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func testAPIGetBranch(t *testing.T, branchName string, exists bool) { | ||
prepareTestEnv(t) | ||
|
||
session := loginUser(t, "user2") | ||
req := NewRequestf(t, "GET", "/api/v1/repos/user2/repo1/branches/%s", branchName) | ||
resp := session.MakeRequest(t, req) | ||
if !exists { | ||
assert.EqualValues(t, http.StatusNotFound, resp.HeaderCode) | ||
return | ||
} | ||
assert.EqualValues(t, http.StatusOK, resp.HeaderCode) | ||
var branch api.Branch | ||
DecodeJSON(t, resp, &branch) | ||
assert.EqualValues(t, branchName, branch.Name) | ||
} | ||
|
||
func TestAPIGetBranch(t *testing.T) { | ||
for _, test := range []struct { | ||
BranchName string | ||
Exists bool | ||
}{ | ||
{"master", true}, | ||
{"master/doesnotexist", false}, | ||
{"feature/1", true}, | ||
{"feature/1/doesnotexist", false}, | ||
} { | ||
testAPIGetBranch(t, test.BranchName, test.Exists) | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
integrations/gitea-integration-meta/gitea-repositories/user2/repo1.git/refs/heads/feature/1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
65f1bf27bc3bf70f64657658635e66094edbcb4d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters