diff options
Diffstat (limited to 'integrations')
-rw-r--r-- | integrations/integration_test.go | 6 | ||||
-rw-r--r-- | integrations/issue_test.go | 5 | ||||
-rw-r--r-- | integrations/links_test.go | 3 | ||||
-rw-r--r-- | integrations/pull_merge_test.go | 6 | ||||
-rw-r--r-- | integrations/release_test.go | 4 | ||||
-rw-r--r-- | integrations/repo_activity_test.go | 4 | ||||
-rw-r--r-- | integrations/repo_branch_test.go | 4 | ||||
-rw-r--r-- | integrations/timetracking_test.go | 6 | ||||
-rw-r--r-- | integrations/user_test.go | 3 |
9 files changed, 24 insertions, 17 deletions
diff --git a/integrations/integration_test.go b/integrations/integration_test.go index d8e97395fa..f3dc98219f 100644 --- a/integrations/integration_test.go +++ b/integrations/integration_test.go @@ -303,9 +303,3 @@ func GetCSRF(t testing.TB, session *TestSession, urlStr string) string { doc := NewHTMLParser(t, resp.Body) return doc.GetCSRF() } - -func RedirectURL(t testing.TB, resp *httptest.ResponseRecorder) string { - urlSlice := resp.HeaderMap["Location"] - assert.NotEmpty(t, urlSlice, "No redirect URL founds") - return urlSlice[0] -} diff --git a/integrations/issue_test.go b/integrations/issue_test.go index d6fd712c9a..10084000db 100644 --- a/integrations/issue_test.go +++ b/integrations/issue_test.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/test" "github.com/PuerkitoBio/goquery" "github.com/stretchr/testify/assert" @@ -122,7 +123,7 @@ func testNewIssue(t *testing.T, session *TestSession, user, repo, title, content }) resp = session.MakeRequest(t, req, http.StatusFound) - issueURL := RedirectURL(t, resp) + issueURL := test.RedirectURL(resp) req = NewRequest(t, "GET", issueURL) resp = session.MakeRequest(t, req, http.StatusOK) @@ -153,7 +154,7 @@ func testIssueAddComment(t *testing.T, session *TestSession, issueURL, content, }) resp = session.MakeRequest(t, req, http.StatusFound) - req = NewRequest(t, "GET", RedirectURL(t, resp)) + req = NewRequest(t, "GET", test.RedirectURL(resp)) resp = session.MakeRequest(t, req, http.StatusOK) htmlDoc = NewHTMLParser(t, resp.Body) diff --git a/integrations/links_test.go b/integrations/links_test.go index bc87ca707a..b0abbd7089 100644 --- a/integrations/links_test.go +++ b/integrations/links_test.go @@ -11,6 +11,7 @@ import ( "testing" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/test" api "code.gitea.io/sdk/gitea" "github.com/stretchr/testify/assert" @@ -54,7 +55,7 @@ func TestRedirectsNoLogin(t *testing.T) { for link, redirectLink := range redirects { req := NewRequest(t, "GET", link) resp := MakeRequest(t, req, http.StatusFound) - assert.EqualValues(t, path.Join(setting.AppSubURL, redirectLink), RedirectURL(t, resp)) + assert.EqualValues(t, path.Join(setting.AppSubURL, redirectLink), test.RedirectURL(resp)) } } diff --git a/integrations/pull_merge_test.go b/integrations/pull_merge_test.go index d6413be549..65ccc93f95 100644 --- a/integrations/pull_merge_test.go +++ b/integrations/pull_merge_test.go @@ -11,6 +11,8 @@ import ( "strings" "testing" + "code.gitea.io/gitea/modules/test" + "github.com/stretchr/testify/assert" ) @@ -54,7 +56,7 @@ func TestPullMerge(t *testing.T) { resp := testPullCreate(t, session, "user1", "repo1", "master") - elem := strings.Split(RedirectURL(t, resp), "/") + elem := strings.Split(test.RedirectURL(resp), "/") assert.EqualValues(t, "pulls", elem[3]) testPullMerge(t, session, elem[1], elem[2], elem[4]) } @@ -67,7 +69,7 @@ func TestPullCleanUpAfterMerge(t *testing.T) { resp := testPullCreate(t, session, "user1", "repo1", "feature/test") - elem := strings.Split(RedirectURL(t, resp), "/") + elem := strings.Split(test.RedirectURL(resp), "/") assert.EqualValues(t, "pulls", elem[3]) testPullMerge(t, session, elem[1], elem[2], elem[4]) diff --git a/integrations/release_test.go b/integrations/release_test.go index bce1c88fdf..461d3306d8 100644 --- a/integrations/release_test.go +++ b/integrations/release_test.go @@ -9,6 +9,8 @@ import ( "net/http" "testing" + "code.gitea.io/gitea/modules/test" + "github.com/Unknwon/i18n" "github.com/stretchr/testify/assert" ) @@ -38,7 +40,7 @@ func createNewRelease(t *testing.T, session *TestSession, repoURL, tag, title st resp = session.MakeRequest(t, req, http.StatusFound) - RedirectURL(t, resp) // check that redirect URL exists + test.RedirectURL(resp) // check that redirect URL exists } func checkLatestReleaseAndCount(t *testing.T, session *TestSession, repoURL, version, label string, count int) { diff --git a/integrations/repo_activity_test.go b/integrations/repo_activity_test.go index 49d07e7c42..d3d2de4a2c 100644 --- a/integrations/repo_activity_test.go +++ b/integrations/repo_activity_test.go @@ -9,6 +9,8 @@ import ( "strings" "testing" + "code.gitea.io/gitea/modules/test" + "github.com/stretchr/testify/assert" ) @@ -20,7 +22,7 @@ func TestRepoActivity(t *testing.T) { testRepoFork(t, session, "user2", "repo1", "user1", "repo1") testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n") resp := testPullCreate(t, session, "user1", "repo1", "master") - elem := strings.Split(RedirectURL(t, resp), "/") + elem := strings.Split(test.RedirectURL(resp), "/") assert.EqualValues(t, "pulls", elem[3]) testPullMerge(t, session, elem[1], elem[2], elem[4]) diff --git a/integrations/repo_branch_test.go b/integrations/repo_branch_test.go index df7f97bd24..c20fd6192c 100644 --- a/integrations/repo_branch_test.go +++ b/integrations/repo_branch_test.go @@ -10,6 +10,8 @@ import ( "strings" "testing" + "code.gitea.io/gitea/modules/test" + "github.com/Unknwon/i18n" "github.com/stretchr/testify/assert" ) @@ -29,7 +31,7 @@ func testCreateBranch(t *testing.T, session *TestSession, user, repo, oldRefSubU if expectedStatus != http.StatusFound { return "" } - return RedirectURL(t, resp) + return test.RedirectURL(resp) } func TestCreateBranch(t *testing.T) { diff --git a/integrations/timetracking_test.go b/integrations/timetracking_test.go index 534bb4d613..890f12b300 100644 --- a/integrations/timetracking_test.go +++ b/integrations/timetracking_test.go @@ -10,6 +10,8 @@ import ( "testing" "time" + "code.gitea.io/gitea/modules/test" + "github.com/stretchr/testify/assert" ) @@ -47,7 +49,7 @@ func testViewTimetrackingControls(t *testing.T, session *TestSession, user, repo if canTrackTime { resp = session.MakeRequest(t, req, http.StatusSeeOther) - req = NewRequest(t, "GET", RedirectURL(t, resp)) + req = NewRequest(t, "GET", test.RedirectURL(resp)) resp = session.MakeRequest(t, req, http.StatusOK) htmlDoc = NewHTMLParser(t, resp.Body) @@ -65,7 +67,7 @@ func testViewTimetrackingControls(t *testing.T, session *TestSession, user, repo }) resp = session.MakeRequest(t, req, http.StatusSeeOther) - req = NewRequest(t, "GET", RedirectURL(t, resp)) + req = NewRequest(t, "GET", test.RedirectURL(resp)) resp = session.MakeRequest(t, req, http.StatusOK) htmlDoc = NewHTMLParser(t, resp.Body) diff --git a/integrations/user_test.go b/integrations/user_test.go index ddb46da317..da39234c3b 100644 --- a/integrations/user_test.go +++ b/integrations/user_test.go @@ -9,6 +9,7 @@ import ( "testing" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/test" "github.com/Unknwon/i18n" "github.com/stretchr/testify/assert" @@ -86,7 +87,7 @@ func TestRenameReservedUsername(t *testing.T) { }) resp := session.MakeRequest(t, req, http.StatusFound) - req = NewRequest(t, "GET", RedirectURL(t, resp)) + req = NewRequest(t, "GET", test.RedirectURL(resp)) resp = session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) assert.Contains(t, |