mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-20 16:10:50 +00:00
Remove session in api tests (#21984)
It's no meaning to request an API route with session.
This commit is contained in:
parent
665d02efaf
commit
df676a47d0
46 changed files with 387 additions and 433 deletions
|
@ -21,7 +21,7 @@ func TestAPIListEmails(t *testing.T) {
|
|||
token := getTokenForLoggedInUser(t, session)
|
||||
|
||||
req := NewRequest(t, "GET", "/api/v1/user/emails?token="+token)
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var emails []*api.Email
|
||||
DecodeJSON(t, resp, &emails)
|
||||
|
@ -52,13 +52,13 @@ func TestAPIAddEmail(t *testing.T) {
|
|||
}
|
||||
|
||||
req := NewRequestWithJSON(t, "POST", "/api/v1/user/emails?token="+token, &opts)
|
||||
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||
MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||
|
||||
opts = api.CreateEmailOption{
|
||||
Emails: []string{"user2-3@example.com"},
|
||||
}
|
||||
req = NewRequestWithJSON(t, "POST", "/api/v1/user/emails?token="+token, &opts)
|
||||
resp := session.MakeRequest(t, req, http.StatusCreated)
|
||||
resp := MakeRequest(t, req, http.StatusCreated)
|
||||
|
||||
var emails []*api.Email
|
||||
DecodeJSON(t, resp, &emails)
|
||||
|
@ -74,7 +74,7 @@ func TestAPIAddEmail(t *testing.T) {
|
|||
Emails: []string{"notAEmail"},
|
||||
}
|
||||
req = NewRequestWithJSON(t, "POST", "/api/v1/user/emails?token="+token, &opts)
|
||||
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||
MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||
}
|
||||
|
||||
func TestAPIDeleteEmail(t *testing.T) {
|
||||
|
@ -88,16 +88,16 @@ func TestAPIDeleteEmail(t *testing.T) {
|
|||
Emails: []string{"user2-3@example.com"},
|
||||
}
|
||||
req := NewRequestWithJSON(t, "DELETE", "/api/v1/user/emails?token="+token, &opts)
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
MakeRequest(t, req, http.StatusNotFound)
|
||||
|
||||
opts = api.DeleteEmailOption{
|
||||
Emails: []string{"user2-2@example.com"},
|
||||
}
|
||||
req = NewRequestWithJSON(t, "DELETE", "/api/v1/user/emails?token="+token, &opts)
|
||||
session.MakeRequest(t, req, http.StatusNoContent)
|
||||
MakeRequest(t, req, http.StatusNoContent)
|
||||
|
||||
req = NewRequest(t, "GET", "/api/v1/user/emails?token="+token)
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var emails []*api.Email
|
||||
DecodeJSON(t, resp, &emails)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue