forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement git refs API for listing references (branches, tags and oth…
…er) (go-gitea#5354) * Inital routes to git refs api * Git refs API implementation * Update swagger * Fix copyright * Make swagger happy add basic test * Fix test * Fix test again :)
- Loading branch information
1 parent
2949043
commit 08bf443
Showing
268 changed files
with
48,603 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,34 @@ | ||
// Copyright 2018 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" | ||
|
||
"code.gitea.io/gitea/models" | ||
) | ||
|
||
func TestAPIReposGitRefs(t *testing.T) { | ||
prepareTestEnv(t) | ||
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) | ||
// Login as User2. | ||
session := loginUser(t, user.Name) | ||
token := getTokenForLoggedInUser(t, session) | ||
|
||
for _, ref := range [...]string{ | ||
"refs/heads/master", // Branch | ||
"refs/tags/v1.1", // Tag | ||
} { | ||
req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/%s?token="+token, user.Name, ref) | ||
session.MakeRequest(t, req, http.StatusOK) | ||
} | ||
// Test getting all refs | ||
req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/refs?token="+token, user.Name) | ||
session.MakeRequest(t, req, http.StatusOK) | ||
// Test getting non-existent refs | ||
req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/refs/heads/unknown?token="+token, user.Name) | ||
session.MakeRequest(t, req, http.StatusNotFound) | ||
} |
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
Oops, something went wrong.