Files
ai-agent/internal/services/wxwork_notify_service_test.go
T

46 lines
1.2 KiB
Go
Raw Normal View History

2026-04-19 18:11:34 +08:00
package services
import (
"testing"
"cs-agent/internal/pkg/config"
)
func TestWxWorkNotifyBuildTextContent(t *testing.T) {
svc := newWxWorkNotifyService()
got := svc.buildTextContent("工单提醒", "这是一条测试消息")
if got != "工单提醒\n\n这是一条测试消息" {
t.Fatalf("unexpected content: %q", got)
}
}
func TestWxWorkNotifyDefaultRecipients(t *testing.T) {
config.SetCurrent(&config.Config{
WxWork: config.WxWorkConfig{
Notify: config.WxWorkNotifyConfig{
Enabled: true,
ToUsers: []string{"user_a", "user_a", "user_b"},
2026-04-19 18:11:34 +08:00
},
},
})
svc := newWxWorkNotifyService()
toUsers := svc.defaultToUsers()
if len(toUsers) != 2 || toUsers[0] != "user_a" || toUsers[1] != "user_b" {
t.Fatalf("unexpected users: %#v", toUsers)
2026-04-19 18:11:34 +08:00
}
}
func TestWxWorkNotifyNormalizeDuplicateCheckInterval(t *testing.T) {
svc := newWxWorkNotifyService()
if got := svc.normalizeDuplicateCheckInterval(0); got != 1800 {
t.Fatalf("expected default interval 1800, got %d", got)
}
if got := svc.normalizeDuplicateCheckInterval(20000); got != 14400 {
t.Fatalf("expected capped interval 14400, got %d", got)
}
if got := svc.normalizeDuplicateCheckInterval(600); got != 600 {
t.Fatalf("expected interval 600, got %d", got)
}
}