Files
dobotai-platform/internal/coverage/notification_test.go
2026-07-27 11:54:34 +08:00

60 lines
1.9 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Package coverage defines the domain logic for coverage evaluation.
package coverage
import (
"reflect"
"testing"
"time"
"gitea.zheromiku.top/Weknora/dobotai-platform/internal/core"
)
func TestSupportNotificationCarriesCustomerQuestionContext(t *testing.T) {
askedAt := time.Date(2026, 7, 24, 10, 16, 35, 0, time.FixedZone("CST", 8*60*60))
notif := SupportNotification{
CaseID: "case-001",
Question: "Nova5I具体支持哪些通信协议?",
SenderName: "张三",
Channel: "dingtalk",
ConversationType: core.ConversationGroup,
AskedAt: askedAt,
PreviousQuestions: []string{
"Nova5I如何配置Modbus TCP?",
"Nova5I是否支持EtherCAT?",
},
FAQRecordID: "record-001",
}
if notif.Question != "Nova5I具体支持哪些通信协议?" || notif.SenderName != "张三" {
t.Fatalf("current question context mismatch: %+v", notif)
}
if !notif.AskedAt.Equal(askedAt) {
t.Fatalf("AskedAt = %v, want %v", notif.AskedAt, askedAt)
}
if len(notif.PreviousQuestions) != 2 || notif.PreviousQuestions[0] != "Nova5I如何配置Modbus TCP?" {
t.Fatalf("PreviousQuestions = %#v", notif.PreviousQuestions)
}
if notif.FAQRecordID != "record-001" {
t.Fatalf("FAQRecordID = %q", notif.FAQRecordID)
}
}
func TestSupportNotificationExcludesAnswerAndRetrievalDiagnostics(t *testing.T) {
typ := reflect.TypeOf(SupportNotification{})
for _, forbidden := range []string{"Answer", "ReferenceCount", "TopScore", "References", "Confidence"} {
if _, ok := typ.FieldByName(forbidden); ok {
t.Errorf("SupportNotification must not expose %s", forbidden)
}
}
}
func TestSupportNotificationEmptyValues(t *testing.T) {
notif := SupportNotification{}
if notif.CaseID != "" || notif.Question != "" || notif.FAQRecordID != "" {
t.Fatalf("expected safe zero value: %+v", notif)
}
if len(notif.PreviousQuestions) != 0 || !notif.AskedAt.IsZero() {
t.Fatalf("expected empty history and time: %+v", notif)
}
}