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:
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
package kb
|
||||
|
||||
import (
|
||||
"agent-desk/cmd/testdata/seedlang"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var hanTextPattern = regexp.MustCompile(`\p{Han}`)
|
||||
|
||||
func TestEnglishKnowledgeBaseTextDoesNotContainChineseText(t *testing.T) {
|
||||
name, description, remark := faqKnowledgeBaseText(seedlang.English)
|
||||
for _, value := range []string{name, description, remark} {
|
||||
if hanTextPattern.MatchString(value) {
|
||||
t.Fatalf("english knowledge base text contains Chinese text: %q", value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnglishKnowledgeFAQSeedsDoNotContainChineseText(t *testing.T) {
|
||||
seeds := knowledgeFAQSeeds(seedlang.English)
|
||||
if len(seeds) == 0 {
|
||||
t.Fatal("english FAQ seeds are empty")
|
||||
}
|
||||
for _, seed := range seeds {
|
||||
values := []string{seed.Question, seed.Answer, seed.Remark}
|
||||
values = append(values, seed.SimilarQuestions...)
|
||||
for _, value := range values {
|
||||
if hanTextPattern.MatchString(value) {
|
||||
t.Fatalf("english FAQ seed contains Chinese text: %q", value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user