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
2017-07-13 13:33:37 +02:00

46 lignes
1,3 Kio
Go

package torrentLanguages
import (
"io/ioutil"
"path"
"strings"
"testing"
"fmt"
"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
)
// run before config/parse.go:init()
var _ = func() (_ struct{}) {
config.ConfigPath = path.Join("..", "..", config.ConfigPath)
config.DefaultConfigPath = path.Join("..", "..", config.DefaultConfigPath)
config.Reload()
config.Get().I18n.Directory = path.Join("..", "..", config.Get().I18n.Directory)
return
}()
func TestCSSFlags(t *testing.T) {
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 {
flag := publicSettings.Flag(language.Code, true)
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)
}
}
}