Merge pull request 'A new test to exercise linguist-language=
' (#2368) from algernon/tests/linguist/view-guess into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2368 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Otto <otto@codeberg.org>
This commit is contained in:
commit
7bf93e5d1a
|
@ -5,6 +5,7 @@ package integration
|
|||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -22,7 +23,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRepoLangStats(t *testing.T) {
|
||||
func TestLinguistSupport(t *testing.T) {
|
||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||
/******************
|
||||
** Preparations **
|
||||
|
@ -219,5 +220,36 @@ func TestRepoLangStats(t *testing.T) {
|
|||
langs := getFreshLanguageStats(t, repo, sha)
|
||||
assert.Empty(t, langs)
|
||||
})
|
||||
|
||||
// 9. Overriding the language
|
||||
t.Run("linguist-language", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
repo, _, f := prep(t, "foo.c linguist-language=sh\n")
|
||||
defer f()
|
||||
|
||||
assertFileLanguage := func(t *testing.T, uri, expectedLanguage string) {
|
||||
t.Helper()
|
||||
|
||||
req := NewRequest(t, "GET", repo.Link()+uri)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
language := strings.TrimSpace(htmlDoc.Find(".file-info .file-info-entry:nth-child(3)").Text())
|
||||
assert.Equal(t, expectedLanguage, language)
|
||||
}
|
||||
|
||||
t.Run("file source view", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
assertFileLanguage(t, "/src/branch/main/foo.c?display=source", "Bash")
|
||||
})
|
||||
|
||||
t.Run("file blame view", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
assertFileLanguage(t, "/blame/branch/main/foo.c", "Bash")
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue