34 lines
867 B
Go
34 lines
867 B
Go
package preview
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"gitea-mail-templates/tools/upstream"
|
|
)
|
|
|
|
func TestNativeLanguageNames(t *testing.T) {
|
|
snapshot, err := upstream.LoadPinned(filepath.Join("..", ".."))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
locales := snapshot.Languages()
|
|
names := languageNames(locales)
|
|
if len(names) != len(locales) {
|
|
t.Fatal("language names do not match preview locales")
|
|
}
|
|
for _, locale := range locales {
|
|
if names[locale] == "" || names[locale] == locale {
|
|
t.Errorf("missing native name for %s", locale)
|
|
}
|
|
}
|
|
for locale, want := range map[string]string{"ga-IE": "Gaeilge", "is-IS": "íslenska"} {
|
|
if names[locale] != want {
|
|
t.Errorf("%s: got %q, want %q", locale, names[locale], want)
|
|
}
|
|
}
|
|
if got := languageNames([]string{"!invalid"})["!invalid"]; got != "!invalid" {
|
|
t.Fatalf("invalid locale fallback: %q", got)
|
|
}
|
|
}
|