Files
olons_server/internal/ai/service_test.go
T

30 lines
876 B
Go

package ai
import (
"strings"
"testing"
)
func TestFallbackTableAnalysisUnparsedProfile(t *testing.T) {
result := fallbackTableAnalysis(TableAnalysisInput{
Topic: "销售分析",
FileID: "file1",
FileName: "sales.xlsx",
FileType: "xlsx",
FileSize: 5149,
Profile: TableProfile{Parsed: false, Message: "source file is not available locally"},
}, Usage{Model: "deepseek-flash"}, "AI 输出格式异常,已使用兜底解读。")
if result.Title != "销售分析" {
t.Fatalf("Title=%q, want 销售分析", result.Title)
}
if strings.TrimSpace(result.Interpretation) == "" {
t.Fatal("Interpretation is empty")
}
if len(result.Alerts) < 2 {
t.Fatalf("Alerts len=%d, want at least 2", len(result.Alerts))
}
if got := result.Metrics[len(result.Metrics)-1].Value; got != "未解析" {
t.Fatalf("last metric value=%q, want 未解析", got)
}
}