diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2022-03-23 05:54:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-23 12:54:07 +0800 |
commit | 3f280f89e7471a6dcdaefccc64a8d39188970e63 (patch) | |
tree | ff09b6dcb00b4c0ff0c436c4523d89a5c13f3a94 /integrations/repo_branch_test.go | |
parent | 395117d3014124b9147a1aabf76ee175e720b275 (diff) | |
download | gitea-3f280f89e7471a6dcdaefccc64a8d39188970e63.tar.gz gitea-3f280f89e7471a6dcdaefccc64a8d39188970e63.zip |
Update HTTP status codes to modern codes (#18063)
* 2xx/3xx/4xx/5xx -> http.Status...
* http.StatusFound -> http.StatusTemporaryRedirect
* http.StatusMovedPermanently -> http.StatusPermanentRedirect
Diffstat (limited to 'integrations/repo_branch_test.go')
-rw-r--r-- | integrations/repo_branch_test.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/integrations/repo_branch_test.go b/integrations/repo_branch_test.go index aef28515e7..ade5d673b9 100644 --- a/integrations/repo_branch_test.go +++ b/integrations/repo_branch_test.go @@ -30,7 +30,7 @@ func testCreateBranch(t testing.TB, session *TestSession, user, repo, oldRefSubU "new_branch_name": newBranchName, }) resp := session.MakeRequest(t, req, expectedStatus) - if expectedStatus != http.StatusFound { + if expectedStatus != http.StatusSeeOther { return "" } return test.RedirectURL(resp) @@ -51,37 +51,37 @@ func testCreateBranches(t *testing.T, giteaURL *url.URL) { { OldRefSubURL: "branch/master", NewBranch: "feature/test1", - ExpectedStatus: http.StatusFound, + ExpectedStatus: http.StatusSeeOther, FlashMessage: i18n.Tr("en", "repo.branch.create_success", "feature/test1"), }, { OldRefSubURL: "branch/master", NewBranch: "", - ExpectedStatus: http.StatusFound, + ExpectedStatus: http.StatusSeeOther, FlashMessage: i18n.Tr("en", "form.NewBranchName") + i18n.Tr("en", "form.require_error"), }, { OldRefSubURL: "branch/master", NewBranch: "feature=test1", - ExpectedStatus: http.StatusFound, + ExpectedStatus: http.StatusSeeOther, FlashMessage: i18n.Tr("en", "repo.branch.create_success", "feature=test1"), }, { OldRefSubURL: "branch/master", NewBranch: strings.Repeat("b", 101), - ExpectedStatus: http.StatusFound, + ExpectedStatus: http.StatusSeeOther, FlashMessage: i18n.Tr("en", "form.NewBranchName") + i18n.Tr("en", "form.max_size_error", "100"), }, { OldRefSubURL: "branch/master", NewBranch: "master", - ExpectedStatus: http.StatusFound, + ExpectedStatus: http.StatusSeeOther, FlashMessage: i18n.Tr("en", "repo.branch.branch_already_exists", "master"), }, { OldRefSubURL: "branch/master", NewBranch: "master/test", - ExpectedStatus: http.StatusFound, + ExpectedStatus: http.StatusSeeOther, FlashMessage: i18n.Tr("en", "repo.branch.branch_name_conflict", "master/test", "master"), }, { @@ -92,21 +92,21 @@ func testCreateBranches(t *testing.T, giteaURL *url.URL) { { OldRefSubURL: "commit/65f1bf27bc3bf70f64657658635e66094edbcb4d", NewBranch: "feature/test3", - ExpectedStatus: http.StatusFound, + ExpectedStatus: http.StatusSeeOther, FlashMessage: i18n.Tr("en", "repo.branch.create_success", "feature/test3"), }, { OldRefSubURL: "branch/master", NewBranch: "v1.0.0", CreateRelease: "v1.0.0", - ExpectedStatus: http.StatusFound, + ExpectedStatus: http.StatusSeeOther, FlashMessage: i18n.Tr("en", "repo.branch.tag_collision", "v1.0.0"), }, { OldRefSubURL: "tag/v1.0.0", NewBranch: "feature/test4", CreateRelease: "v1.0.1", - ExpectedStatus: http.StatusFound, + ExpectedStatus: http.StatusSeeOther, FlashMessage: i18n.Tr("en", "repo.branch.create_success", "feature/test4"), }, } @@ -116,7 +116,7 @@ func testCreateBranches(t *testing.T, giteaURL *url.URL) { createNewRelease(t, session, "/user2/repo1", test.CreateRelease, test.CreateRelease, false, false) } redirectURL := testCreateBranch(t, session, "user2", "repo1", test.OldRefSubURL, test.NewBranch, test.ExpectedStatus) - if test.ExpectedStatus == http.StatusFound { + if test.ExpectedStatus == http.StatusSeeOther { req := NewRequest(t, "GET", redirectURL) resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) @@ -135,7 +135,7 @@ func TestCreateBranchInvalidCSRF(t *testing.T) { "_csrf": "fake_csrf", "new_branch_name": "test", }) - resp := session.MakeRequest(t, req, http.StatusFound) + resp := session.MakeRequest(t, req, http.StatusSeeOther) loc := resp.Header().Get("Location") assert.Equal(t, setting.AppSubURL+"/", loc) resp = session.MakeRequest(t, NewRequest(t, "GET", loc), http.StatusOK) |