mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +00:00
Merge pull request '[gitea] week 2024-50 cherry pick (gitea/main -> forgejo)' (#6200) from earl-warren/wcp/2024-50 into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6200 Reviewed-by: Otto <otto@codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
commit
021c8fe15a
13 changed files with 142 additions and 232 deletions
|
@ -43,6 +43,24 @@ func TestPackageSwift(t *testing.T) {
|
|||
|
||||
url := fmt.Sprintf("/api/packages/%s/swift", user.Name)
|
||||
|
||||
t.Run("CheckLogin", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
req := NewRequestWithBody(t, "POST", url, strings.NewReader(""))
|
||||
MakeRequest(t, req, http.StatusUnauthorized)
|
||||
|
||||
req = NewRequestWithBody(t, "POST", url, strings.NewReader("")).
|
||||
AddBasicAuth(user.Name)
|
||||
MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
req = NewRequestWithBody(t, "POST", url+"/login", strings.NewReader(""))
|
||||
MakeRequest(t, req, http.StatusUnauthorized)
|
||||
|
||||
req = NewRequestWithBody(t, "POST", url+"/login", strings.NewReader("")).
|
||||
AddBasicAuth(user.Name)
|
||||
MakeRequest(t, req, http.StatusOK)
|
||||
})
|
||||
|
||||
t.Run("CheckAcceptMediaType", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
|
|
|
@ -6,14 +6,18 @@ package integration
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -47,3 +51,23 @@ func TestRepoCloneWiki(t *testing.T) {
|
|||
})
|
||||
})
|
||||
}
|
||||
|
||||
func Test_RepoWikiPages(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
url := "/user2/repo1/wiki/?action=_pages"
|
||||
req := NewRequest(t, "GET", url)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
doc := NewHTMLParser(t, resp.Body)
|
||||
expectedPagePaths := []string{
|
||||
"Home", "Long-Page", "Page-With-Image", "Page-With-Spaced-Name", "Unescaped-File",
|
||||
}
|
||||
doc.Find("tr").Each(func(i int, s *goquery.Selection) {
|
||||
firstAnchor := s.Find("a").First()
|
||||
href, _ := firstAnchor.Attr("href")
|
||||
pagePath := strings.TrimPrefix(href, "/user2/repo1/wiki/")
|
||||
|
||||
assert.EqualValues(t, expectedPagePaths[i], pagePath)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue