Remove session in api tests (#21984)

It's no meaning to request an API route with session.
This commit is contained in:
Lunny Xiao 2022-12-02 11:39:42 +08:00 committed by GitHub
parent 665d02efaf
commit df676a47d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 387 additions and 433 deletions

View file

@ -27,7 +27,7 @@ func TestAPIListStopWatches(t *testing.T) {
session := loginUser(t, owner.Name)
token := getTokenForLoggedInUser(t, session)
req := NewRequestf(t, "GET", "/api/v1/user/stopwatches?token=%s", token)
resp := session.MakeRequest(t, req, http.StatusOK)
resp := MakeRequest(t, req, http.StatusOK)
var apiWatches []*api.StopWatch
DecodeJSON(t, resp, &apiWatches)
stopwatch := unittest.AssertExistsAndLoadBean(t, &issues_model.Stopwatch{UserID: owner.ID})
@ -54,8 +54,8 @@ func TestAPIStopStopWatches(t *testing.T) {
token := getTokenForLoggedInUser(t, session)
req := NewRequestf(t, "POST", "/api/v1/repos/%s/%s/issues/%d/stopwatch/stop?token=%s", owner.Name, issue.Repo.Name, issue.Index, token)
session.MakeRequest(t, req, http.StatusCreated)
session.MakeRequest(t, req, http.StatusConflict)
MakeRequest(t, req, http.StatusCreated)
MakeRequest(t, req, http.StatusConflict)
}
func TestAPICancelStopWatches(t *testing.T) {
@ -70,8 +70,8 @@ func TestAPICancelStopWatches(t *testing.T) {
token := getTokenForLoggedInUser(t, session)
req := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/issues/%d/stopwatch/delete?token=%s", owner.Name, issue.Repo.Name, issue.Index, token)
session.MakeRequest(t, req, http.StatusNoContent)
session.MakeRequest(t, req, http.StatusConflict)
MakeRequest(t, req, http.StatusNoContent)
MakeRequest(t, req, http.StatusConflict)
}
func TestAPIStartStopWatches(t *testing.T) {
@ -86,6 +86,6 @@ func TestAPIStartStopWatches(t *testing.T) {
token := getTokenForLoggedInUser(t, session)
req := NewRequestf(t, "POST", "/api/v1/repos/%s/%s/issues/%d/stopwatch/start?token=%s", owner.Name, issue.Repo.Name, issue.Index, token)
session.MakeRequest(t, req, http.StatusCreated)
session.MakeRequest(t, req, http.StatusConflict)
MakeRequest(t, req, http.StatusCreated)
MakeRequest(t, req, http.StatusConflict)
}