Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

delete_user_test.go 932B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package integrations
  5. import (
  6. "net/http"
  7. "testing"
  8. "code.gitea.io/gitea/models"
  9. "github.com/stretchr/testify/assert"
  10. )
  11. func TestDeleteUser(t *testing.T) {
  12. prepareTestEnv(t)
  13. session := loginUser(t, "user1")
  14. req := NewRequest(t, "GET", "/admin/users/8")
  15. resp := session.MakeRequest(t, req)
  16. assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
  17. doc := NewHTMLParser(t, resp.Body)
  18. req = NewRequestWithValues(t, "POST", "/admin/users/8/delete", map[string]string{
  19. "_csrf": doc.GetCSRF(),
  20. })
  21. req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
  22. resp = session.MakeRequest(t, req)
  23. assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
  24. models.AssertNotExistsBean(t, &models.User{ID: 8})
  25. models.CheckConsistencyFor(t, &models.User{})
  26. }