-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#15203) * fix bitbucket server scm provider EOF on empty repo default branch check * add unit test for bitbucketServer empty repo * check for EOF explicitly --------- Signed-off-by: Jedrzej Kotkowski <[email protected]> Co-authored-by: jjsiv <[email protected]>
- Loading branch information
1 parent
e982e0b
commit bf77b09
Showing
2 changed files
with
26 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
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 |
---|---|---|
|
@@ -365,6 +365,28 @@ func TestGetBranchesMissingDefault(t *testing.T) { | |
assert.Empty(t, repos) | ||
} | ||
|
||
func TestGetBranchesEmptyRepo(t *testing.T) { | ||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
assert.Empty(t, r.Header.Get("Authorization")) | ||
switch r.RequestURI { | ||
case "/rest/api/1.0/projects/PROJECT/repos/REPO/branches/default": | ||
return | ||
} | ||
})) | ||
defer ts.Close() | ||
provider, err := NewBitbucketServerProviderNoAuth(context.Background(), ts.URL, "PROJECT", false) | ||
assert.NoError(t, err) | ||
repos, err := provider.GetBranches(context.Background(), &Repository{ | ||
Organization: "PROJECT", | ||
Repository: "REPO", | ||
URL: "ssh://[email protected]/PROJECT/REPO.git", | ||
Labels: []string{}, | ||
RepositoryId: 1, | ||
}) | ||
assert.Empty(t, repos) | ||
assert.NoError(t, err) | ||
} | ||
|
||
func TestGetBranchesErrorDefaultBranch(t *testing.T) { | ||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
assert.Empty(t, r.Header.Get("Authorization")) | ||
|