loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

Gusted 7bf93e5d fd01298a

+33 -1
+33 -1
tests/integration/repo_lang_stats_test.go tests/integration/linguist_test.go
··· 5 5 6 6 import ( 7 7 "context" 8 + "net/http" 8 9 "net/url" 9 10 "strings" 10 11 "testing" ··· 22 23 "github.com/stretchr/testify/assert" 23 24 ) 24 25 25 - func TestRepoLangStats(t *testing.T) { 26 + func TestLinguistSupport(t *testing.T) { 26 27 onGiteaRun(t, func(t *testing.T, u *url.URL) { 27 28 /****************** 28 29 ** Preparations ** ··· 218 219 219 220 langs := getFreshLanguageStats(t, repo, sha) 220 221 assert.Empty(t, langs) 222 + }) 223 + 224 + // 9. Overriding the language 225 + t.Run("linguist-language", func(t *testing.T) { 226 + defer tests.PrintCurrentTest(t)() 227 + 228 + repo, _, f := prep(t, "foo.c linguist-language=sh\n") 229 + defer f() 230 + 231 + assertFileLanguage := func(t *testing.T, uri, expectedLanguage string) { 232 + t.Helper() 233 + 234 + req := NewRequest(t, "GET", repo.Link()+uri) 235 + resp := MakeRequest(t, req, http.StatusOK) 236 + htmlDoc := NewHTMLParser(t, resp.Body) 237 + 238 + language := strings.TrimSpace(htmlDoc.Find(".file-info .file-info-entry:nth-child(3)").Text()) 239 + assert.Equal(t, expectedLanguage, language) 240 + } 241 + 242 + t.Run("file source view", func(t *testing.T) { 243 + defer tests.PrintCurrentTest(t)() 244 + 245 + assertFileLanguage(t, "/src/branch/main/foo.c?display=source", "Bash") 246 + }) 247 + 248 + t.Run("file blame view", func(t *testing.T) { 249 + defer tests.PrintCurrentTest(t)() 250 + 251 + assertFileLanguage(t, "/blame/branch/main/foo.c", "Bash") 252 + }) 221 253 }) 222 254 }) 223 255 }