@@ -5,6 +5,7 @@ package integration
55
66import (
77 "context"
8+ "net/http"
89 "net/url"
910 "strings"
1011 "testing"
@@ -22,7 +23,7 @@ import (
2223 "github.com/stretchr/testify/assert"
2324)
2425
25- func TestRepoLangStats (t * testing.T ) {
26+ func TestLinguistSupport (t * testing.T ) {
2627 onGiteaRun (t , func (t * testing.T , u * url.URL ) {
2728 /******************
2829 ** Preparations **
@@ -219,5 +220,36 @@ func TestRepoLangStats(t *testing.T) {
219220 langs := getFreshLanguageStats (t , repo , sha )
220221 assert .Empty (t , langs )
221222 })
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+ })
253+ })
222254 })
223255}
0 commit comments