diff options
author | Ethan Koenig <etk39@cornell.edu> | 2017-05-20 04:48:22 -0400 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-05-20 16:48:22 +0800 |
commit | cf02cd7ba0c94165743660cf30f0cbb5a73a385e (patch) | |
tree | 6f09dce7c705041df1e042750137e379b0af66dc /integrations/delete_user_test.go | |
parent | 85a73965256411c36ecc050eeb7967d3c8ef20d5 (diff) | |
download | gitea-cf02cd7ba0c94165743660cf30f0cbb5a73a385e.tar.gz gitea-cf02cd7ba0c94165743660cf30f0cbb5a73a385e.zip |
Fix and test for delete user (#1713)
* Fix and test for delete user
* Run updates in batches
* Unit test
Diffstat (limited to 'integrations/delete_user_test.go')
-rw-r--r-- | integrations/delete_user_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/integrations/delete_user_test.go b/integrations/delete_user_test.go new file mode 100644 index 0000000000..bf38eeae2b --- /dev/null +++ b/integrations/delete_user_test.go @@ -0,0 +1,41 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package integrations + +import ( + "bytes" + "net/http" + "net/url" + "testing" + + "code.gitea.io/gitea/models" + + "github.com/stretchr/testify/assert" +) + +func TestDeleteUser(t *testing.T) { + prepareTestEnv(t) + + session := loginUser(t, "user1", "password") + + req, err := http.NewRequest("GET", "/admin/users/8", nil) + assert.NoError(t, err) + resp := session.MakeRequest(t, req) + assert.EqualValues(t, http.StatusOK, resp.HeaderCode) + + doc, err := NewHtmlParser(resp.Body) + assert.NoError(t, err) + req, err = http.NewRequest("POST", "/admin/users/8/delete", + bytes.NewBufferString(url.Values{ + "_csrf": []string{doc.GetInputValueByName("_csrf")}, + }.Encode())) + assert.NoError(t, err) + req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + resp = session.MakeRequest(t, req) + assert.EqualValues(t, http.StatusOK, resp.HeaderCode) + + models.AssertNotExistsBean(t, &models.User{ID: 8}) + models.CheckConsistencyFor(t, &models.User{}) +} |