Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/utils/torrentLanguages/torrent_languages_test.go

47 lignes
1,3 Kio
Go
Brut Vue normale Historique

package torrentLanguages
import (
"io/ioutil"
"path"
"strings"
"testing"
2017-07-11 21:34:06 +02:00
"fmt"
"github.com/NyaaPantsu/nyaa/config"
2017-07-11 21:34:06 +02:00
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
)
// run before config/parse.go:init()
var _ = func() (_ struct{}) {
config.Configpaths[1] = path.Join("..", "..", config.Configpaths[1])
config.Configpaths[0] = path.Join("..", "..", config.Configpaths[0])
config.Reload()
2017-07-11 21:34:06 +02:00
config.Get().I18n.Directory = path.Join("..", "..", config.Get().I18n.Directory)
return
}()
func TestCSSFlags(t *testing.T) {
2017-07-11 21:34:06 +02:00
var retriever publicSettings.UserRetriever // not required during initialization
err := publicSettings.InitI18n(config.Get().I18n, retriever)
if err != nil {
t.Errorf("failed to initialize language translations: %v", err)
}
languages := GetTorrentLanguages()
flagsCSSPath := path.Join("..", "..", "public", "css", "flags", "flags.css")
file, err := ioutil.ReadFile(flagsCSSPath)
if err != nil {
t.Errorf("Failed to load flags.css: %v", err)
return
}
contents := string(file)
for _, language := range languages {
2017-07-13 13:33:37 +02:00
flag := publicSettings.Flag(language.Code, true)
2017-07-11 21:34:06 +02:00
fmt.Printf("Finding css class for: %s (%s)\n", flag, language.Name)
if !strings.Contains(contents, ".flag-"+flag) {
t.Errorf("flags.css does not contains class .flag-%s. You probably need to update it.", flag)
}
}
}