summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
authorCirno the Strongest <1447794+CirnoT@users.noreply.github.com>2020-05-11 11:44:36 +0200
committerGitHub <noreply@github.com>2020-05-11 12:44:36 +0300
commit32b8172e56c38d98ce493f31a30e1642e29a9030 (patch)
tree8cc6d9a66a0af925aa06e5a59e060456bd4d09a0 /integrations
parent59b9b77a0dce02076195c5f6402afbbb6edd9deb (diff)
downloadgitea-32b8172e56c38d98ce493f31a30e1642e29a9030.tar.gz
gitea-32b8172e56c38d98ce493f31a30e1642e29a9030.zip
Consolidate API for getting single commit (#11368)
* Allow Git ref for /repos/{owner}/{repo}/git/commits/{sha} * Consolidate API for getting single commit * Fix tests and do it differently Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'integrations')
-rw-r--r--integrations/api_repo_git_commits_test.go28
1 files changed, 6 insertions, 22 deletions
diff --git a/integrations/api_repo_git_commits_test.go b/integrations/api_repo_git_commits_test.go
index f710811ea7..5b0f82e854 100644
--- a/integrations/api_repo_git_commits_test.go
+++ b/integrations/api_repo_git_commits_test.go
@@ -21,18 +21,14 @@ func TestAPIReposGitCommits(t *testing.T) {
session := loginUser(t, user.Name)
token := getTokenForLoggedInUser(t, session)
- //check invalid requests for GetCommitsBySHA
- req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/commits/master?token="+token, user.Name)
- session.MakeRequest(t, req, http.StatusUnprocessableEntity)
-
- req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/commits/12345?token="+token, user.Name)
+ // check invalid requests
+ req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/commits/12345?token="+token, user.Name)
session.MakeRequest(t, req, http.StatusNotFound)
- //check invalid requests for GetCommitsByRef
- req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/commits/..?token="+token, user.Name)
+ req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/commits/..?token="+token, user.Name)
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
- req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/commits/branch-not-exist?token="+token, user.Name)
+ req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/commits/branch-not-exist?token="+token, user.Name)
session.MakeRequest(t, req, http.StatusNotFound)
for _, ref := range [...]string{
@@ -41,20 +37,8 @@ func TestAPIReposGitCommits(t *testing.T) {
"65f1", // short sha
"65f1bf27bc3bf70f64657658635e66094edbcb4d", // full sha
} {
- req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/commits/%s?token="+token, user.Name, ref)
- resp := session.MakeRequest(t, req, http.StatusOK)
- commitByRef := new(api.Commit)
- DecodeJSON(t, resp, commitByRef)
- assert.Len(t, commitByRef.SHA, 40)
- assert.EqualValues(t, commitByRef.SHA, commitByRef.RepoCommit.Tree.SHA)
- req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/commits/%s?token="+token, user.Name, commitByRef.SHA)
- resp = session.MakeRequest(t, req, http.StatusOK)
- commitBySHA := new(api.Commit)
- DecodeJSON(t, resp, commitBySHA)
-
- assert.EqualValues(t, commitByRef.SHA, commitBySHA.SHA)
- assert.EqualValues(t, commitByRef.HTMLURL, commitBySHA.HTMLURL)
- assert.EqualValues(t, commitByRef.RepoCommit.Message, commitBySHA.RepoCommit.Message)
+ req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/commits/%s?token="+token, user.Name, ref)
+ session.MakeRequest(t, req, http.StatusOK)
}
}