mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-27 12:53:57 +01:00
Add result check in TestAPIEditUser (#29674)
Fix #29514 There are too many usage of `NewRequestWithValues`, so there's no need to check all of them. Just one is enough I think. (cherry picked from commit ecd1d96f494d2400f7659165ff9376354edda395) Conflicts: - tests/integration/api_admin_test.go Conflict resolved by manually applying the change to `full_name`.
This commit is contained in:
parent
2b2fd2728c
commit
f81890fa95
1 changed files with 5 additions and 2 deletions
|
@ -195,10 +195,13 @@ func TestAPIEditUser(t *testing.T) {
|
||||||
token := getUserToken(t, adminUsername, auth_model.AccessTokenScopeWriteAdmin)
|
token := getUserToken(t, adminUsername, auth_model.AccessTokenScopeWriteAdmin)
|
||||||
urlStr := fmt.Sprintf("/api/v1/admin/users/%s", "user2")
|
urlStr := fmt.Sprintf("/api/v1/admin/users/%s", "user2")
|
||||||
|
|
||||||
|
fullNameToChange := "Full Name User 2"
|
||||||
req := NewRequestWithValues(t, "PATCH", urlStr, map[string]string{
|
req := NewRequestWithValues(t, "PATCH", urlStr, map[string]string{
|
||||||
"full_name": "Full Name User 2",
|
"full_name": fullNameToChange,
|
||||||
}).AddTokenAuth(token)
|
}).AddTokenAuth(token)
|
||||||
MakeRequest(t, req, http.StatusOK)
|
MakeRequest(t, req, http.StatusOK)
|
||||||
|
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{LoginName: "user2"})
|
||||||
|
assert.Equal(t, fullNameToChange, user2.FullName)
|
||||||
|
|
||||||
empty := ""
|
empty := ""
|
||||||
req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{
|
req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{
|
||||||
|
@ -210,7 +213,7 @@ func TestAPIEditUser(t *testing.T) {
|
||||||
json.Unmarshal(resp.Body.Bytes(), &errMap)
|
json.Unmarshal(resp.Body.Bytes(), &errMap)
|
||||||
assert.EqualValues(t, "e-mail invalid [email: ]", errMap["message"].(string))
|
assert.EqualValues(t, "e-mail invalid [email: ]", errMap["message"].(string))
|
||||||
|
|
||||||
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{LoginName: "user2"})
|
user2 = unittest.AssertExistsAndLoadBean(t, &user_model.User{LoginName: "user2"})
|
||||||
assert.False(t, user2.IsRestricted)
|
assert.False(t, user2.IsRestricted)
|
||||||
bTrue := true
|
bTrue := true
|
||||||
req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{
|
req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{
|
||||||
|
|
Loading…
Reference in a new issue