aboutsummaryrefslogtreecommitdiffstats
path: root/tests/integration/api_repo_git_trees_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-12-02 11:39:42 +0800
committerGitHub <noreply@github.com>2022-12-01 22:39:42 -0500
commitdf676a47d05b20f7bfe4fdae350f50af15b52905 (patch)
treedc747e21fd2a533aeacb1686f747bba0a8f60736 /tests/integration/api_repo_git_trees_test.go
parent665d02efaf6ebaadf3ffb5b412ea77c4502f0baf (diff)
downloadgitea-df676a47d05b20f7bfe4fdae350f50af15b52905.tar.gz
gitea-df676a47d05b20f7bfe4fdae350f50af15b52905.zip
Remove session in api tests (#21984)
It's no meaning to request an API route with session.
Diffstat (limited to 'tests/integration/api_repo_git_trees_test.go')
-rw-r--r--tests/integration/api_repo_git_trees_test.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/tests/integration/api_repo_git_trees_test.go b/tests/integration/api_repo_git_trees_test.go
index b99326e1ac..d1d49e4627 100644
--- a/tests/integration/api_repo_git_trees_test.go
+++ b/tests/integration/api_repo_git_trees_test.go
@@ -29,7 +29,6 @@ func TestAPIReposGitTrees(t *testing.T) {
// Login as User2.
session := loginUser(t, user2.Name)
token := getTokenForLoggedInUser(t, session)
- session = emptyTestSession(t) // don't want anyone logged in for this
// Test a public repo that anyone can GET the tree of
for _, ref := range [...]string{
@@ -37,7 +36,7 @@ func TestAPIReposGitTrees(t *testing.T) {
repo1TreeSHA, // Tree SHA
} {
req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/%s", user2.Name, repo1.Name, ref)
- session.MakeRequest(t, req, http.StatusOK)
+ MakeRequest(t, req, http.StatusOK)
}
// Tests a private repo with no token so will fail
@@ -46,31 +45,30 @@ func TestAPIReposGitTrees(t *testing.T) {
repo1TreeSHA, // Tag
} {
req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/%s", user2.Name, repo16.Name, ref)
- session.MakeRequest(t, req, http.StatusNotFound)
+ MakeRequest(t, req, http.StatusNotFound)
}
// Test using access token for a private repo that the user of the token owns
req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/%s?token=%s", user2.Name, repo16.Name, repo16TreeSHA, token)
- session.MakeRequest(t, req, http.StatusOK)
+ MakeRequest(t, req, http.StatusOK)
// Test using bad sha
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/%s", user2.Name, repo1.Name, badSHA)
- session.MakeRequest(t, req, http.StatusBadRequest)
+ MakeRequest(t, req, http.StatusBadRequest)
// Test using org repo "user3/repo3" where user2 is a collaborator
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/%s?token=%s", user3.Name, repo3.Name, repo3TreeSHA, token)
- session.MakeRequest(t, req, http.StatusOK)
+ MakeRequest(t, req, http.StatusOK)
// Test using org repo "user3/repo3" with no user token
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/%s", user3.Name, repo3TreeSHA, repo3.Name)
- session.MakeRequest(t, req, http.StatusNotFound)
+ MakeRequest(t, req, http.StatusNotFound)
// Login as User4.
session = loginUser(t, user4.Name)
token4 := getTokenForLoggedInUser(t, session)
- session = emptyTestSession(t) // don't want anyone logged in for this
// Test using org repo "user3/repo3" where user4 is a NOT collaborator
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/d56a3073c1dbb7b15963110a049d50cdb5db99fc?access=%s", user3.Name, repo3.Name, token4)
- session.MakeRequest(t, req, http.StatusNotFound)
+ MakeRequest(t, req, http.StatusNotFound)
}