Files
Erupe/server/channelserver/sys_language_test.go
Houmgaor f17cb96b52 refactor(config): rename package _config to config with cfg alias
The config package used `package _config` with a leading underscore,
which is unconventional in Go. Rename to `package config` (matching the
directory name) and use `cfg` as the standard import alias across all
93 importing files.
2026-02-21 13:20:15 +01:00

95 lines
2.0 KiB
Go

package channelserver
import (
"testing"
cfg "erupe-ce/config"
)
func TestGetLangStrings_English(t *testing.T) {
server := &Server{
erupeConfig: &cfg.Config{
Language: "en",
},
}
lang := getLangStrings(server)
if lang.language != "English" {
t.Errorf("language = %q, want %q", lang.language, "English")
}
// Verify key strings are not empty
if lang.cafe.reset == "" {
t.Error("cafe.reset should not be empty")
}
if lang.commands.disabled == "" {
t.Error("commands.disabled should not be empty")
}
if lang.commands.reload == "" {
t.Error("commands.reload should not be empty")
}
if lang.commands.ravi.noCommand == "" {
t.Error("commands.ravi.noCommand should not be empty")
}
if lang.guild.invite.title == "" {
t.Error("guild.invite.title should not be empty")
}
}
func TestGetLangStrings_Japanese(t *testing.T) {
server := &Server{
erupeConfig: &cfg.Config{
Language: "jp",
},
}
lang := getLangStrings(server)
if lang.language != "日本語" {
t.Errorf("language = %q, want %q", lang.language, "日本語")
}
// Verify Japanese strings are different from English
enServer := &Server{
erupeConfig: &cfg.Config{
Language: "en",
},
}
enLang := getLangStrings(enServer)
if lang.commands.reload == enLang.commands.reload {
t.Error("Japanese commands.reload should be different from English")
}
}
func TestGetLangStrings_DefaultToEnglish(t *testing.T) {
server := &Server{
erupeConfig: &cfg.Config{
Language: "unknown_language",
},
}
lang := getLangStrings(server)
// Unknown language should default to English
if lang.language != "English" {
t.Errorf("Unknown language should default to English, got %q", lang.language)
}
}
func TestGetLangStrings_EmptyLanguage(t *testing.T) {
server := &Server{
erupeConfig: &cfg.Config{
Language: "",
},
}
lang := getLangStrings(server)
// Empty language should default to English
if lang.language != "English" {
t.Errorf("Empty language should default to English, got %q", lang.language)
}
}