feat: add language support and tests for English and Chinese seed data
- Introduced a new package `seedlang` to handle language parsing and constants for English and Chinese. - Updated `Init` functions across various modules (kb, quickreply, skill, tag) to accept a language parameter. - Implemented English seed data for FAQs, quick replies, skills, and tags, ensuring no Chinese text is present in English data. - Added tests to verify that English seed data does not contain Chinese characters. - Removed outdated README file from the kb test data directory. - Created new test files for channel and kb to validate the absence of Chinese text in English seed data.
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
package seedlang
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestParseDefaultsToChinese(t *testing.T) {
|
||||
lang, err := Parse("")
|
||||
if err != nil {
|
||||
t.Fatalf("Parse empty returned error: %v", err)
|
||||
}
|
||||
if lang != Chinese {
|
||||
t.Fatalf("Parse empty = %q, want %q", lang, Chinese)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseEnglishAliases(t *testing.T) {
|
||||
for _, raw := range []string{"en", "EN", "english", "English"} {
|
||||
lang, err := Parse(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("Parse(%q) returned error: %v", raw, err)
|
||||
}
|
||||
if lang != English {
|
||||
t.Fatalf("Parse(%q) = %q, want %q", raw, lang, English)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseRejectsUnsupportedLanguage(t *testing.T) {
|
||||
if _, err := Parse("fr"); err == nil {
|
||||
t.Fatal("Parse unsupported language returned nil error")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user