diff options
author | Ethan Koenig <etk39@cornell.edu> | 2017-06-17 00:49:45 -0400 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-06-17 12:49:45 +0800 |
commit | ce9b86082c4824917023b1bb480648d0cc56dd04 (patch) | |
tree | ba28673c955d009492557f54953857165e2f8da8 /integrations/delete_user_test.go | |
parent | a3868ef5367315f52334b81819a412cad820f5eb (diff) | |
download | gitea-ce9b86082c4824917023b1bb480648d0cc56dd04.tar.gz gitea-ce9b86082c4824917023b1bb480648d0cc56dd04.zip |
Consolidate boilerplate in integration tests (#1979)
Diffstat (limited to 'integrations/delete_user_test.go')
-rw-r--r-- | integrations/delete_user_test.go | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/integrations/delete_user_test.go b/integrations/delete_user_test.go index 2040830f2e..c5230d0220 100644 --- a/integrations/delete_user_test.go +++ b/integrations/delete_user_test.go @@ -5,9 +5,7 @@ package integrations import ( - "bytes" "net/http" - "net/url" "testing" "code.gitea.io/gitea/models" @@ -18,18 +16,16 @@ import ( func TestDeleteUser(t *testing.T) { prepareTestEnv(t) - session := loginUser(t, "user1", "password") + session := loginUser(t, "user1") req := NewRequest(t, "GET", "/admin/users/8") resp := session.MakeRequest(t, req) assert.EqualValues(t, http.StatusOK, resp.HeaderCode) - doc, err := NewHtmlParser(resp.Body) - assert.NoError(t, err) - req = NewRequestBody(t, "POST", "/admin/users/8/delete", - bytes.NewBufferString(url.Values{ - "_csrf": []string{doc.GetInputValueByName("_csrf")}, - }.Encode())) + doc := NewHtmlParser(t, resp.Body) + req = NewRequestWithValues(t, "POST", "/admin/users/8/delete", map[string]string{ + "_csrf": doc.GetCSRF(), + }) req.Header.Add("Content-Type", "application/x-www-form-urlencoded") resp = session.MakeRequest(t, req) assert.EqualValues(t, http.StatusOK, resp.HeaderCode) |