1
0
Fork 0
forked from forgejo/forgejo

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

@ -68,7 +68,7 @@ func testAPIListOAuth2Applications(t *testing.T) {
urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2?token=%s", token)
req := NewRequest(t, "GET", urlStr)
resp := session.MakeRequest(t, req, http.StatusOK)
resp := MakeRequest(t, req, http.StatusOK)
var appList api.OAuth2ApplicationList
DecodeJSON(t, resp, &appList)
@ -95,13 +95,13 @@ func testAPIDeleteOAuth2Application(t *testing.T) {
urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2/%d?token=%s", oldApp.ID, token)
req := NewRequest(t, "DELETE", urlStr)
session.MakeRequest(t, req, http.StatusNoContent)
MakeRequest(t, req, http.StatusNoContent)
unittest.AssertNotExistsBean(t, &auth.OAuth2Application{UID: oldApp.UID, Name: oldApp.Name})
// Delete again will return not found
req = NewRequest(t, "DELETE", urlStr)
session.MakeRequest(t, req, http.StatusNotFound)
MakeRequest(t, req, http.StatusNotFound)
}
func testAPIGetOAuth2Application(t *testing.T) {
@ -120,7 +120,7 @@ func testAPIGetOAuth2Application(t *testing.T) {
urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2/%d?token=%s", existApp.ID, token)
req := NewRequest(t, "GET", urlStr)
resp := session.MakeRequest(t, req, http.StatusOK)
resp := MakeRequest(t, req, http.StatusOK)
var app api.OAuth2Application
DecodeJSON(t, resp, &app)