diff options
author | Giteabot <teabot@gitea.io> | 2024-05-05 21:17:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-05 21:17:03 +0800 |
commit | 054602977a8b142881460b46ddaafaf3c04c6a3d (patch) | |
tree | d0fe6127c661158e202f4126bb1486592189ca81 | |
parent | 471b411873fd14f2fb161322022863680e294d75 (diff) | |
download | gitea-054602977a8b142881460b46ddaafaf3c04c6a3d.tar.gz gitea-054602977a8b142881460b46ddaafaf3c04c6a3d.zip |
Add result check in TestAPIEditUser (#29674) (#30860)
Backport #29674 by @yp05327
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.
Co-authored-by: yp05327 <576951401@qq.com>
-rw-r--r-- | tests/integration/api_admin_test.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/integration/api_admin_test.go b/tests/integration/api_admin_test.go index e8954f5b20..92da7ce041 100644 --- a/tests/integration/api_admin_test.go +++ b/tests/integration/api_admin_test.go @@ -195,14 +195,17 @@ func TestAPIEditUser(t *testing.T) { token := getUserToken(t, adminUsername, auth_model.AccessTokenScopeWriteAdmin) urlStr := fmt.Sprintf("/api/v1/admin/users/%s", "user2") + fullNameToChange := "Full Name User 2" req := NewRequestWithValues(t, "PATCH", urlStr, map[string]string{ // required "login_name": "user2", "source_id": "0", // to change - "full_name": "Full Name User 2", + "full_name": fullNameToChange, }).AddTokenAuth(token) MakeRequest(t, req, http.StatusOK) + user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{LoginName: "user2"}) + assert.Equal(t, fullNameToChange, user2.FullName) empty := "" req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{ @@ -216,7 +219,7 @@ func TestAPIEditUser(t *testing.T) { json.Unmarshal(resp.Body.Bytes(), &errMap) 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) bTrue := true req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{ |