diff options
author | Ethan Koenig <ethantkoenig@gmail.com> | 2017-12-03 14:46:01 -0800 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-12-04 00:46:01 +0200 |
commit | e59adcde655aac0e8afd3249407c9a0a2b1b1d6b (patch) | |
tree | a1b5859eadfe6ffdfc106012b7eab13a16459813 /integrations/editor_test.go | |
parent | 993b86628bdf62c0565c2a57a73561bb2d535b22 (diff) | |
download | gitea-e59adcde655aac0e8afd3249407c9a0a2b1b1d6b.tar.gz gitea-e59adcde655aac0e8afd3249407c9a0a2b1b1d6b.zip |
Use httptest in integration tests (#3080)
Diffstat (limited to 'integrations/editor_test.go')
-rw-r--r-- | integrations/editor_test.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/integrations/editor_test.go b/integrations/editor_test.go index 712cc91fbc..0722a917f0 100644 --- a/integrations/editor_test.go +++ b/integrations/editor_test.go @@ -6,6 +6,7 @@ package integrations import ( "net/http" + "net/http/httptest" "path" "testing" @@ -72,7 +73,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) { resp = session.MakeRequest(t, req, http.StatusOK) // Check body for error message - assert.Contains(t, string(resp.Body), "Can not commit to protected branch 'master'.") + assert.Contains(t, resp.Body.String(), "Can not commit to protected branch 'master'.") // remove the protected branch csrf = GetCSRF(t, session, "/user2/repo1/settings/branches") @@ -89,7 +90,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) { } -func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePath, newContent string) *TestResponse { +func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePath, newContent string) *httptest.ResponseRecorder { // Get to the 'edit this file' page req := NewRequest(t, "GET", path.Join(user, repo, "_edit", branch, filePath)) resp := session.MakeRequest(t, req, http.StatusOK) @@ -113,12 +114,12 @@ func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePa // Verify the change req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", branch, filePath)) resp = session.MakeRequest(t, req, http.StatusOK) - assert.EqualValues(t, newContent, string(resp.Body)) + assert.EqualValues(t, newContent, resp.Body.String()) return resp } -func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, branch, targetBranch, filePath, newContent string) *TestResponse { +func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, branch, targetBranch, filePath, newContent string) *httptest.ResponseRecorder { // Get to the 'edit this file' page req := NewRequest(t, "GET", path.Join(user, repo, "_edit", branch, filePath)) @@ -144,7 +145,7 @@ func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, bra // Verify the change req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", targetBranch, filePath)) resp = session.MakeRequest(t, req, http.StatusOK) - assert.EqualValues(t, newContent, string(resp.Body)) + assert.EqualValues(t, newContent, resp.Body.String()) return resp } |